Applies to: SmarterMail 3.x
This sample is in Microsoft.Net 1.1. The techniques shown here applies to any receiving mail server.
MailMessage eMail = new MailMessage();
eMail.To = " mailto:joe@example.com";
eMail.From = " mailto:sender@example.com";
eMail.Subject = "hello there";
// Set CC and BCC records here
eMail.Body = bodyText;
if(attachments != null)
{
foreach(FileInfo fi in attachments)
{
MailAttachment att = new MailAttachment(fi.FullName);
eMail.Attachments.Add(att);
}
}
// Set SMTP SERVER to send through
eMail.Fields[" http://schemas.microsoft.com/cdo/configuration/smtpserver"] = smtpServer;
eMail.Fields[" http://schemas.microsoft.com/cdo/configuration/smtpserverport"] = 25;
//1 = Send message using the local SMTP service pickup directory. 2 = SMTP over the network.
eMail.Fields[" http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
// Set SMTP Authentication credentials
if (smtpAuthUserName != null && smtpAuthUserName.Length > 0 && smtpAuthPassword != null)
{
eMail.Fields[" http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
eMail.Fields[" http://schemas.microsoft.com/cdo/configuration/sendusername"] = smtpAuthUserName;
eMail.Fields[" http://schemas.microsoft.com/cdo/configuration/sendpassword"] = smtpAuthPassword;
}
SmtpMail.Send(eMail);
Article ID: 30, Created On: 2/21/2005, Modified: 5/26/2010