private System.Net.Mail.MailMessage m;
string Subject = "FOO";
string Message = "F001";
string email = "FOO2";
string strField = "F003";
//PDF,DOC etc
string extn = "PDF";
//application/pdf etc
string strType = "application/pdf";
// This needs filling for attachment to be added
System.IO.MemoryStream memstream;
m = new System.Net.Mail.MailMessage();
m.From = new System.Net.Mail.MailAddress(strEmailAddress);
m.IsBodyHtml = false;
m.Subject = Subject;
m.Body = Message;
System.Net.Mail.MailAddress aTo = new System.Net.Mail.MailAddress(email);
m.To.Add(aTo);
if (memstream.Length != 0)
{
memstream.Position = 0;
m.Attachments.Add(new System.Net.Mail.Attachment(memstream, strField + "." + extn, strType));
}
System.Net.Mail.SmtpClient smServer = new System.Net.Mail.SmtpClient(Configuration.Instance.EmailServer);
smServer.Send(m);
Friday, 17 December 2010
dotNet Mailer
Standard chunk of mailing code.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment