Sending email getting problem
-
Hi all I am using ASP.Net 3.5 and send email using smtp server when i host my application i am getting the below error: The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for name@domain.com My Code::: Dim objMail As New MailMessage Try objMail.From = "name@domain.com" objMail.To = "name@domain.com" objMail.BodyFormat = MailFormat.Text objMail.Priority = MailPriority.High objMail.Subject = "My first ASP.NET email" objMail.Body = "This is my first email sent via " SmtpMail.SmtpServer = "server ip address" SmtpMail.Send(objMail) Catch ex As Exception Response.Write(ex.Message) End Try Thanks in advance
Er. Jagwinder Singh
-
Hi all I am using ASP.Net 3.5 and send email using smtp server when i host my application i am getting the below error: The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for name@domain.com My Code::: Dim objMail As New MailMessage Try objMail.From = "name@domain.com" objMail.To = "name@domain.com" objMail.BodyFormat = MailFormat.Text objMail.Priority = MailPriority.High objMail.Subject = "My first ASP.NET email" objMail.Body = "This is my first email sent via " SmtpMail.SmtpServer = "server ip address" SmtpMail.Send(objMail) Catch ex As Exception Response.Write(ex.Message) End Try Thanks in advance
Er. Jagwinder Singh
You may need to authenticate to your email server so you would need to add that to your code. Below is a code snippet using cdosys, that i tested answering a similar question the other day. Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="youremail@yourdomain.com" myMail.To="youremail@yourdomain.com" myMail.TextBody="This is a message." myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 'Name or IP of remote SMTP server myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="youremailserver" 'Server port myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 'authenticate myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'email address for authentication myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youremailaddresshere" 'email password myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "youremailpasswordhere" myMail.Configuration.Fields.Update myMail.Send set myMail=nothing Hope this helps
Matthew Vass QA Analyst mvass@hostmysite.com HostMySite.com