msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.OnSuccess | DeliveryNotificationOptions.Delay;
msg.Headers.Add("Disposition-Notification-To", "chris@splinter.com.au");
using System.Net.Mail; ... MailMessage msg = new MailMessage(); msg.From = new MailAddress("me@wherever.com","My name"); msg.To.Add("recipient1@abcdef.com"); // Who's it to msg.To.Add("recipient2@abcdef.com"); msg.CC.Add("recipient3@abcdef.com"); // CC recipient(s) msg.CC.Add("recipient4@abcdef.com"); msg.Subject = "Subject line"; msg.Body = "<html><h1>Big header</h1><p>And some smaller text</p></html>" msg.IsBodyHtml = msg.Body.Contains("<html>"); // Delivery notifications msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.OnSuccess | DeliveryNotificationOptions.Delay; // Ask for a read receipt msg.Headers.Add("Disposition-Notification-To", "chris@splinter.com.au"); // Attachment(s) byte[] data = File.ReadAllBytes("attachment.dat"); msg.Attachments.Add(new Attachment(new MemoryStream(data),"MyAttachment.dat")); // Send it new SmtpClient("my-smtp-server").Send(msg);
Thanks for reading! And if you want to get in touch, I'd love to hear from you: chris.hulbert at gmail.
(Comp Sci, Hons - UTS)
Software Developer (Freelancer / Contractor) in Australia.
I have worked at places such as Google, Cochlear, Assembly Payments, News Corp, Fox Sports, NineMSN, FetchTV, Coles, Woolworths, Trust Bank, and Westpac, among others. If you're looking for help developing an iOS app, drop me a line!
Get in touch:
chris.hulbert@gmail.com
github.com/chrishulbert
linkedin