Guest User

Untitled

a guest
Oct 18th, 2017
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. using(MailMessage message = new MailMessage("john.smith@gmail.com"){
  2. MemoryStream stream;
  3. //here I pass byte array to the stream and create an attachemnt
  4. message.Attachments.Add(new Attachment(stream, "name.xyz"));
  5.  
  6. using(SmtpClient client = new SmtpClient("server.com", port))
  7. {
  8. // send message
  9. }
  10. }
  11.  
  12. try
  13. {
  14. client.Send(messgae);
  15. }
  16. finally
  17. {
  18. if(stream != null)
  19. stream.Dispose();
  20. }
Add Comment
Please, Sign In to add comment