Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async void btn_send_Click(object sender, RoutedEventArgs e)
- {
- string name = "test.jpg";
- var folder = KnownFolders.PicturesLibrary;
- var file = await folder.GetFileAsync(name);
- CitiKioskService.Service1Client kioskclient = new CitiKioskService.Service1Client();
- kioskclient.Endpoint.Address = new EndpointAddress(new Uri(new SettingsViewModel().KioskWebServiceURL));
- string email_address = tb_email.Text;
- 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";
- await kioskclient.sendEmailWithAttachAsync(email_address, "Visit Photo", message, file);
- }
- await kioskclient.sendEmailWithAttachAsync(email_address, "Visit Photo", message, file);
- public List<string> sendEmailWithAttach(string toAddress, string subject, string body, string attachment)
- {
- List<string> message = new List<string>();
- String msg = "";
- try
- {
- SmtpMail oMail = new SmtpMail("TryIt");
- EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
- // Set your hotmail/live/outlook.com email address
- oMail.From = new EASendMail.MailAddress("live@hotmail.com");
- // Add recipient email address
- oMail.To.Add(new EASendMail.MailAddress(toAddress));
- // Set email subject and email body text
- oMail.Subject = subject;
- oMail.TextBody = body;
- // Send attachment
- string attfile = attachment;
- EASendMail.Attachment oAttachment = oMail.AddAttachment(attfile);
- // Hotmail SMTP server
- SmtpServer oServer = new SmtpServer("smtp.live.com");
- // User and password for ESMTP authentication
- oServer.User = "live@hotmail.com";
- oServer.Password = "password";
- oServer.Port = 25;
- // detect SSL/TLS type automatically
- oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
- oSmtp.SendMail(oServer, oMail);
- msg = "Email was sent successfully!";
- }
- catch (SmtpFailedRecipientException ex)
- {
- msg = ex.GetBaseException().ToString();
- message.Add(ex.GetBaseException().ToString());
- }
- return message;
- }
Add Comment
Please, Sign In to add comment