Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,


I have the follow code in c#:

C#
.....
smtpServer="smpt.gmail.com";
#endregion
message.From        = from; // text in from--> 'leochat777@gmail.com'
message.To      = to;   // text in to--> 'leocomp7@yahoo.com'
message.Cc          = cc;
message.Subject     = subject;
message.Priority    = MailPriority.High;
message.Body        = BodyEmail( mensaje, nombreCliente );
message.BodyFormat  = MailFormat.Html;
SmtpMail.SmtpServer = smtpServer;     // text in smtpServer--->'smtp.gmail.com'
try
{
  SmtpMail.Send(message);
  retorna = true;
}
catch(Exception er)
{
  throw new Exception ("Existe un error con el servidor de correo, no pudo enviar el email : "+er.Message,er.InnerException);
}


Then ocurr an error and said me:

'cant access to 'CDO.Message' object'

And inside the catch.

Please give me the solution for send the messague successfully

Thanks in advance
Leonardo Ayala R.
Posted
Comments
Thomas Daniels 25-Jan-14 12:12pm    
There is a typo in the smtpServer variable: you wrote smpt instead of smtp. Do you also get the error after fixing that?
leocode7 25-Jan-14 12:19pm    
ok, thanks, i will comments to you the result to make this change :)
leocode7 25-Jan-14 12:27pm    
My friend I would comment to you that the problem continue. I think that the problem is the VLan of my company, now I cant try with another network for security reasons in my company.

but the code is perfectly really???

If you copied your code exactly, this:

C#
smtpServer="smpt.gmail.com";


Should really be this:

C#
smtpServer="smtp.gmail.com";


You wrote smpt when it should be smtp. I'm not sure if this will solve your error, but it is one of them. You should also set the port for gmail to 587 I believe instead of the default.
 
Share this answer
 
Comments
leocode7 25-Jan-14 12:31pm    
How set the port with SmtpMail class I look only one property: 'SmtpServer' NO MORE..????
Ron Beyer 25-Jan-14 22:00pm    
Unfortunately you are using an obsoleted mail component, it is recommended for .NET 2.0 and up to change over to the
try this

C#
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.Subject = "Subject";
msg.From = new System.Net.Mail.MailAddress("From");
msg.To.Add(new System.Net.Mail.MailAddress("To"));

msg.IsBodyHtml = true;
msg.Body = "Message Body";
System.Net.Mail.SmtpClient smpt = new System.Net.Mail.SmtpClient();
smpt.Host = "smtp.gmail.com";
smpt.Port = "Port no.(Integer value)";
smpt.EnableSsl = true;
smpt.Credentials = new System.Net.NetworkCredential("(From)User Id", "Password");
smpt.Send(msg);
retVal = true;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900