Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using(MailMessage message = new MailMessage("john.smith@gmail.com"){
- MemoryStream stream;
- //here I pass byte array to the stream and create an attachemnt
- message.Attachments.Add(new Attachment(stream, "name.xyz"));
- using(SmtpClient client = new SmtpClient("server.com", port))
- {
- // send message
- }
- }
- try
- {
- client.Send(messgae);
- }
- finally
- {
- if(stream != null)
- stream.Dispose();
- }
Add Comment
Please, Sign In to add comment