Guest User

Untitled

a guest
May 27th, 2018
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1.         public static void Send()
  2.         {
  3.                 MailMessage mail = new MailMessage();
  4.                 SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
  5.                 mail.From = new MailAddress("LynxClientLogFileMailer@gmail.com", "Lynx Client");
  6.                 mail.To.Add(new MailAddress("LynxClientLogFileMailer@gmail.com", "Lynx Client"));
  7.                 //ail.To.Add(new MailAddress("Lynx3@mitsi.com", "Lynx Technical Support"));
  8.  
  9.                 mail.Subject = "Lynx Client Logs for machine: " + Environment.MachineName;
  10.                 mail.Body = "mail with attachment";
  11.  
  12.                 System.Net.Mail.Attachment attachment;
  13.                 foreach (string filename in Directory.GetFiles(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "debugpackagedata")))
  14.                 {
  15.                     if (filename.EndsWith(".zip"))
  16.                     {
  17.                         attachment = new System.Net.Mail.Attachment(filename);
  18.                         mail.Attachments.Add(attachment);
  19.                     }
  20.                 }
  21.  
  22.                 SmtpServer.Port = 587;
  23.                 SmtpServer.Credentials = new System.Net.NetworkCredential("LynxClientLogFileMailer@gmail.com", "mitsilynx");
  24.                 SmtpServer.EnableSsl = true;
  25.                 SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
  26.  
  27.                 SmtpServer.Send(mail);
  28.                 //MessageBox.Show("mail Send");
  29.         }
Add Comment
Please, Sign In to add comment