Advertisement
Guest User

Untitled

a guest
May 28th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1.  
  2. #r "~/packages/Sendgrid.5.1.0/lib/SendGridMail.dll"
  3. #r "~/packages/SendGrid.SmtpApi.1.2.1/lib/net40/SendGrid.SmtpApi.dll"
  4.  
  5. open System
  6. open System.Collections.Generic
  7. open System.Net
  8. open System.Net.Mail
  9. open SendGrid
  10.  
  11. let message = new SendGridMessage()
  12. message.From <- new MailAddress("snadella@microsoft.com")
  13. let recipients = new List<string>()
  14. recipients.Add("bgates@microsoft.com")
  15. message.AddTo(recipients)
  16.  
  17. message.Subject <- "Testing the SendGrid Library"
  18. message.Html <- "<p>Hello World!</p>"
  19. message.Text <- "Hello world plain text!"
  20.  
  21. let username = "yourNameHere";
  22. let pswd = "yourPasswordHere";
  23. let credentials = new NetworkCredential(username, pswd);
  24. let transportWeb = new Web(credentials);
  25.  
  26. try
  27. let mailResult = transportWeb.Deliver(message);
  28. ()
  29. with
  30. | :? Exceptions.InvalidApiRequestException as ex -> ex.Errors |> Seq.iter( fun e -> printfn "Exception! %s " e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement