Guest User

Untitled

a guest
Nov 9th, 2017
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. private async void btn_send_Click(object sender, RoutedEventArgs e)
  2. {
  3. string name = "test.jpg";
  4. var folder = KnownFolders.PicturesLibrary;
  5. var file = await folder.GetFileAsync(name);
  6.  
  7.  
  8. CitiKioskService.Service1Client kioskclient = new CitiKioskService.Service1Client();
  9. kioskclient.Endpoint.Address = new EndpointAddress(new Uri(new SettingsViewModel().KioskWebServiceURL));
  10. string email_address = tb_email.Text;
  11. string message = "Dear visitor, the following attachment is the photo taken during your visit. Thank You. This is a system generated email. Please do not reply to this email";
  12. await kioskclient.sendEmailWithAttachAsync(email_address, "Visit Photo", message, file);
  13.  
  14.  
  15. }
  16.  
  17. await kioskclient.sendEmailWithAttachAsync(email_address, "Visit Photo", message, file);
  18.  
  19. public List<string> sendEmailWithAttach(string toAddress, string subject, string body, string attachment)
  20. {
  21. List<string> message = new List<string>();
  22. String msg = "";
  23. try
  24. {
  25. SmtpMail oMail = new SmtpMail("TryIt");
  26. EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
  27.  
  28. // Set your hotmail/live/outlook.com email address
  29. oMail.From = new EASendMail.MailAddress("live@hotmail.com");
  30.  
  31. // Add recipient email address
  32. oMail.To.Add(new EASendMail.MailAddress(toAddress));
  33.  
  34. // Set email subject and email body text
  35. oMail.Subject = subject;
  36. oMail.TextBody = body;
  37.  
  38.  
  39. // Send attachment
  40. string attfile = attachment;
  41. EASendMail.Attachment oAttachment = oMail.AddAttachment(attfile);
  42.  
  43. // Hotmail SMTP server
  44. SmtpServer oServer = new SmtpServer("smtp.live.com");
  45.  
  46. // User and password for ESMTP authentication
  47. oServer.User = "live@hotmail.com";
  48. oServer.Password = "password";
  49.  
  50.  
  51. oServer.Port = 25;
  52.  
  53. // detect SSL/TLS type automatically
  54. oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
  55.  
  56. oSmtp.SendMail(oServer, oMail);
  57. msg = "Email was sent successfully!";
  58.  
  59. }
  60. catch (SmtpFailedRecipientException ex)
  61. {
  62. msg = ex.GetBaseException().ToString();
  63. message.Add(ex.GetBaseException().ToString());
  64. }
  65.  
  66. return message;
  67. }
Add Comment
Please, Sign In to add comment