Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. // Attach the message string to this e-mail message.
  2. //var reader = new StreamReader(@"c:Temptelephone.txt");
  3. string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "telephone.txt");
  4.  
  5.  
  6. Attachment data = new Attachment(path, MediaTypeNames.Text.Plain);
  7.  
  8. // Send textMessage as part of the e-mail body.
  9. message.Attachments.Add(data);
  10. ContentDisposition disposition = data.ContentDisposition;
  11. disposition.Inline = true;
  12. message.Attachments[0].ContentId = "telephone.txt";
  13.  
  14. //Send the message.
  15. // Include credentials if the server requires them.
  16. SmtpClient client = new SmtpClient(server);
  17. client.Credentials = CredentialCache.DefaultNetworkCredentials;
  18.  
  19. try
  20. {
  21. client.Send(message);
  22. }
  23. catch (Exception ex)
  24. {
  25. Console.WriteLine("Exception caught in CreateMessageInlineAttachment: {0}",
  26. ex.ToString());
  27. }
  28. data.Dispose();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement