Advertisement
Guest User

Untitled

a guest
Oct 7th, 2017
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. Content-type: text/html; charset=US-ASCII
  2. Content-Disposition: inline
  3. Content-transfer-encoding: quoted-printable
  4.  
  5. Content-type: text/plain; name="..."
  6. Content-Disposition: attachment; filename="..."
  7. Content-transfer-encoding: base64
  8.  
  9. //Для отправки почты
  10. static void SendMail()
  11. {
  12. string smtpHost = "хост почтовик";
  13. int smtpPort = порт;
  14. string login = "логин";
  15. string pass = "пароль";
  16.  
  17. //connect
  18. SmtpClient client = new SmtpClient(smtpHost, smtpPort);
  19. client.Credentials = new NetworkCredential(login, pass);
  20.  
  21. //from-to-title-body message
  22. string from = "test@gmail.com";
  23. string to = "test1@gmail.com, test2@gmail.com";
  24. string subject = "Test header";
  25. string body = "Это тестовая рассылка, проверьте вложение";
  26.  
  27. //attachment
  28. Attachment attData = new Attachment(@"C:test.xlsx");
  29.  
  30. //create message and attaching
  31. MailMessage mess = new MailMessage(from, to, subject, body);
  32. mess.Attachments.Add(attData);
  33.  
  34. try
  35. {
  36. client.Send(mess);
  37. MessageBox.Show("Сообщение отправлено");
  38. }
  39.  
  40. catch (SmtpException ex)
  41. {
  42. MessageBox.Show(ex);
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement