|
Source code samples |
|
The following source code samples demonstrate how easy it is to send an email using MailMill
.NET.
The code is written in C# but could be in any other .NET
programming languages. |
|
Simple text message |
MailMill.Mail oMail = new Mail();
oMail.From = "John <john@emilltest.com>";
oMail.Tos.Add("Brian <brian@emilltest.com>");
oMail.Subject = "A very simple mail";
oMail.TextBody = "Hello World!";
oMail.Server = "smtp.mydomain.tld";
oMail.Send(); |
|
HTML message with embedded images
|
MailMill.Mail oMail = new Mail();
oMail.From = "Lisa <lisa@emilltest.com>";
oMail.Tos.Add("Bernard <bernard@emilltest.com>");
oMail.Subject = "An HTML mail that contains images";
oMail.HtmlBody = "<html><body>Hello <img src=c:\\images\\world.gif></body></html>";
oMail.TextBody = "Hello World!"; // optional
alternate text
oMail.Server = "smtp.mydomain.tld";
oMail.Send();
// The local image will automatically be
embedded in the MIME. |
|
Text message with a static attachment
|
MailMill.Mail oMail
= new Mail();
oMail.From = "John <john@emilltest.com>";
oMail.Tos.Add("Brian <brian@emilltest.com>");
oMail.Subject = "A mail with an attachment" ;
oMail.TextBody = "Please find attached your invoice";
oMail.Attachments.Add(@"c:\invoices\invoice.pdf");
oMail.Server = "smtp.mydomain.tld";
oMail.Send(); |
|
Text message with a dynamic attachment
|
MailMill.Mail oMail = new Mail();
oMail.From = "John <john@emilltest.com>";
oMail.Tos.Add("Caroline <caroline@emilltest.com>");
oMail.Subject = "A mail with an attachment";
oMail.TextBody = "Please find attached your monthly commission
report";
MailMill.MailAttachment oAttach = new MailAttachment();
oAttach.Name = DateTime.Now.Year + "-" + DateTime.Now.Month +
"-comission.txt";
oAttach.Type = "text/plain";
oAttach.Data = "This month your will receive a commission of
$7,589.78.\r\nKeep up the good work.";
oMail.Attachments.Add(oAttach);
oMail.Server = "smtp.mydomain.tld";
oMail.Send(); |