using System.Web.Mail;
MailMessage msg = new MailMessage();
msg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
msg.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "username";
msg.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "password";
msg.To = "to";
msg.From = "from";
msg.Subject = "sbuject";
msg.Body = "body";
SmtpMail.SmtpServer = "smtpserver";