MailMessage msg = new MailMessage(); // To and From are required by SmtpMail. msg.To = Recipient; msg.From = Sender; msg.Subject = Subject; msg.Body = Message; msg.BodyFormat = MailFormat.Text; msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username"); //set your username here msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password"); //set your password here SmtpMail.SmtpServer = Server; SmtpMail.Send(msg);
must add: message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "userName"); message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "pwd"); but this has some uncertainty: microsoft's cdo servise can shutdown . so you had better use vendor tool
msg.To = Recipient;
msg.From = Sender;
msg.Subject = Subject;
msg.Body = Message;
msg.BodyFormat = MailFormat.Text;
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username"); //set your username here
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password"); //set your password here
SmtpMail.SmtpServer = Server;
SmtpMail.Send(msg);
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "userName");
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "pwd");
but this has some uncertainty:
microsoft's cdo servise can shutdown .
so you had better use vendor tool