Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- log.LogInformation("########## Starting ##########");
- var apiKey = "Send Grid API Key";
- log.LogInformation(apiKey);
- var client = new SendGridClient(apiKey);
- var from = new EmailAddress("email id", "Example User");
- var subject = "Sending with SendGrid is Fun";
- var to = new EmailAddress("email id", "Example User");
- var plainTextContent = "and easy to do anywhere, even with C#";
- var htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";
- var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
- string storagefilename = "Storage file name";
- WebClient client1 = new WebClient();
- Stream stream = client1.OpenRead(storagefilename);
- StreamReader reader = new StreamReader(stream);
- String content = reader.ReadToEnd();
- byte[] byteArray = Encoding.ASCII.GetBytes(content);
- log.LogInformation("####### " + byteArray);
- msg.Attachments = new List<SendGrid.Helpers.Mail.Attachment>
- {
- new SendGrid.Helpers.Mail.Attachment
- {
- Content = Convert.ToBase64String(byteArray),
- Filename = "Transcript.pdf",
- Disposition = "attachment"
- }
- };
- var response = client.SendEmailAsync(msg);
- log.LogInformation("####### Mail Sent ###########");
- string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement