Tuesday, July 20, 2010

How can I send an Email in my web site using ASP.NET 2.0?

I have written a code in asp.net 2.0 and tested that in a web site to send emils to users, but it fails. The error message is:


Not Local host yahoo.com, not gateway.


How can I solve this problem. Do I need Authentication? If so, how shaould I do it? The Code is:





Dim objSMTP As New SmtpClient("mail.mydomian.com")


Dim mailSubject As String = txtSubject.Text


Dim mailBody As String = txtBody.Text


Dim objMailMsg As New MailMessage("support@mydomain.com", txtTo.Text)


objMailMsg.Subject = mailSubject


objMailMsg.Body = mailBody


objSMTP.Send(objMailMsg)


objMailMsg.Dispose()

How can I send an Email in my web site using ASP.NET 2.0?
The SMTP server that you specified in the first line may need authentication. Many SMTP servers don't need authentication but only send mail for certain people, such as an ISP's server that only sends mail for its customers. You'll need to contact the owner of that SMTP server.





You may have removed this from the code you posted, but you haven't given the MailMessage a From or To address.





Dan


http://easiersoftware.blogspot.com


No comments:

Post a Comment