The problem with sending mail

Sep 16 2010 11:24 PM

Hi all.
i am uisng visual studio 2003 to create simple web for sending mail base on the smtp server like that :
 
 

string smtpServer = "smtp.gmail.com";
string userName = "metilmarket";
string password = "i5kngyvx";
int cdoBasic = 1;
int cdoSendUsingPort = 2;
MailMessage msg = new MailMessage();
if (userName.Length > 0)
{
msg.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer);
msg.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);
msg.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort);
msg.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic);
msg.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendusername", userName);
msg.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
}
msg.To =
"[email protected]";
msg.From =
"[email protected]";
msg.Subject =
"Subject";
msg.Body =
"Message";
SmtpMail.SmtpServer = smtpServer;
SmtpMail.Send(msg);
lb1mgs.Text =
"Your message has been successfully sent.";

But i am get error when i do the transaction with smtp :
errors like that :
The server rejected the sender address. The server response was: 530 5.7.0 Must issue a STARTTLS command  first. n35sm3933492wfa.15
 i am using gmail to test this application.
 Please give me suggestion , how to correct it ?
 
thanks in advances.
 

 

Answers (7)