Black Rock Reporting Azure Function
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

MailSenderFunction.cs 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.IO;
  3. using Microsoft.Azure.Functions.Worker;
  4. using Microsoft.Extensions.Logging;
  5. using SendGrid.Helpers.Mail;
  6. using Microsoft.Azure.WebJobs;
  7. namespace BlackRockReportFunction
  8. {
  9. public class MailSenderFunction
  10. {
  11. private readonly ILogger _logger;
  12. public MailSenderFunction(ILoggerFactory loggerFactory)
  13. {
  14. _logger = loggerFactory.CreateLogger<MailSenderFunction>();
  15. }
  16. //http://127.0.0.1:10000/devstoreaccount1/report-container
  17. [Function("MailSenderFunction")]
  18. public SendGridMessage Run([BlobTrigger("report-container/{name}", Connection = "AzureWebJobsStorage")] string fileData, string fileName)
  19. {
  20. _logger.LogInformation($"C# Blob trigger function Processed blob\n Name: {fileName} \n Data: {fileData}");
  21. var msg = new SendGridMessage()
  22. {
  23. From = new EmailAddress("nikola.jovanovic@dilig.net", "Nikola Jovanovic"),
  24. Subject = "Test SendGrid Azure Function",
  25. PlainTextContent = String.Format("If you read this text, then congratulations," +
  26. " you did it! :)")
  27. };
  28. msg.AddTo(new EmailAddress("nikolajovanovic3579@gmail.com", "Nikola Jovanovic"));
  29. return msg;
  30. }
  31. }
  32. }