I want send Email using Asp.net3.5, c#.net. I am able to send it using smtp.gmail.com with my ID [email protected], but my client given there details to send from there Id. With that I am unable to send. Details looks different like .Ex. xxx.xxx.com not like smtp.gmail.com there is no SMTP word in that host name. Please help me, how to send Email?
-
2Can you add your current code? So we can have a look at where it might go wrong.Bazzz– Bazzz2011-02-14 10:16:19 +00:00Commented Feb 14, 2011 at 10:16
-
code is working fine if i give my gmail details like Host: Smtp.gmail.com band uid :[email protected] pwd: xxxx.but when i changed to their details only unable to sendsanthosh– santhosh2011-02-14 10:32:23 +00:00Commented Feb 14, 2011 at 10:32
-
what error message (exception) do you receive when you try to send the mail with your clients credetials? "With that I am unable to send" doesn't give us enough information to help you. =)Rob– Rob2011-02-14 10:46:08 +00:00Commented Feb 14, 2011 at 10:46
3 Answers
System.Web.Mail.MailMessage message=new System.Web.Mail.MailMessage();
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1 );
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername","SmtpHostUserName" );
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword","SmtpHostPassword" );
message.From="from e-mail";
message.To="to e-mail";
message.Subject="Message Subject";
message.Body="Message Body";
System.Web.Mail.SmtpMail.SmtpServer="SMTP Server Address";
System.Web.Mail.SmtpMail.Send(message);
For More info check this
Comments
instead of using smtp.gmail.com use mail.XXX.com, you will be able to sent mail.
4 Comments
smtp or mail in it for it to be acting as a mail server. It could be called potato.domain.com and still be a mailserver =)There are a lot of sites on the net which will give you explanation and code as to how you can send mails in asp.net 3.5. You just need to google a bit. I have listed some sites which might be helpful to you. Compare your code with the ones given on these sites and check where you have made a mistake. Also if you can post your code here then we would be in a better position to help you out.
http://www.c-sharpcorner.com/UploadFile/dchoksi/SendingMail02132007002923AM/SendingMail.aspx
http://www.dotnetcurry.com/ShowArticle.aspx?ID=65&AspxAutoDetectCookieSupport=1
http://www.eggheadcafe.com/articles/20030720.asp
http://jalpesh.blogspot.com/2009/07/sending-email-through.html
Regards,
Samar