Adding an attachment to the email

Perform the following steps:

  1. Add the following code to the Run method of the SendNotifications function, and save the changes by clicking on the Save button:
message.AddAttachment(FirstName +"_"+LastName+".log",
System.Convert.ToBase64String
(System.Text.Encoding.UTF8.GetBytes
(emailContent)),

"text/plain",
"attachment",
"Logs"
);
  1. Run a test using the same request payload that we have used in the previous recipes.
  2. This is the screenshot of the email, along with the attachment:
You can learn more about the Send Grid API at  https://sendgrid.com/docs/API_Reference/api_v3.html.