Saturday, March 24, 2012

Trouble sending email with ASP.NET 2.0

I have an ASP.NET 2.0 application that is supposed to send an email after a
certain form is submitted. When it tries to send the email, I receive the
following error:

Transaction failed. The server response was: njsokalski@dotnet.itags.org.hotmail.com:
Recipient address rejected: Access denied

(in the error message, the part with the email address was displayed as
<myemailaddress>, but you will probably see a link because our news viewers
think they know what we want). I know that the address is correct, so what
is it that the server didn't like about it? Is it saying I don't have
permission to use the SMTP server (I was pretty sure I was, but this is the
first time I am sending email from this server)? Is there something wrong
with my code? Any help would be appreciated. Thanks.
--
Nathan Sokalski
njsokalski@dotnet.itags.org.hotmail.com
http://www.nathansokalski.com/On Fri, 5 Jan 2007 03:55:44 -0500, "Nathan Sokalski"
<njsokalski@.hotmail.comwrote:

Quote:

Originally Posted by

Is there something wrong
>with my code? Any help would be appreciated. Thanks.


You didn't provide your code, so it is hard to tell.

However, this works for me:

Try
Dim mail As New Mail.MailMessage()

mail.From = New Mail.MailAddress("mail@.mail.somewhere",
"Subject")
mail.To.Add("another@.mail.somewhere")

mail.Subject = "Subject"
mail.Body = "Body"

Dim smtp As New Mail.SmtpClient("mail.planprojekt.dk")
smtp.Credentials = New
NetworkCredential("mail@.mail.somewhere", "password")
smtp.Send(mail)

bEmailSent = True
Catch ex As Exception
Exit Sub
End Try

/Snedker
The code I am using is as follows:

Private Sub SendEmailNotification()
Dim confsender As New
SmtpClient(System.Configuration.ConfigurationManag er.AppSettings("smtpserver"))
Dim confirmation As New MailMessage()
confirmation.IsBodyHtml = False
confirmation.From = New MailAddress("fromaddress@.mydomain.com")
confirmation.To.Add("njsokalski@.hotmail.com")
confirmation.Subject = "My Subject"
confirmation.Body = "My Body"

confsender.Send(confirmation)
End Sub

Thanks.
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"Morten Snedker" <morten_spammenot_ATdbconsult.dkwrote in message
news:2p6sp2dqb6qkfg0j60i3gt12iqvhdgcj70@.4ax.com...

Quote:

Originally Posted by

On Fri, 5 Jan 2007 03:55:44 -0500, "Nathan Sokalski"
<njsokalski@.hotmail.comwrote:
>

Quote:

Originally Posted by

>Is there something wrong
>>with my code? Any help would be appreciated. Thanks.


>
You didn't provide your code, so it is hard to tell.
>
However, this works for me:
>
Try
Dim mail As New Mail.MailMessage()
>
mail.From = New Mail.MailAddress("mail@.mail.somewhere",
"Subject")
mail.To.Add("another@.mail.somewhere")
>
mail.Subject = "Subject"
mail.Body = "Body"
>
Dim smtp As New Mail.SmtpClient("mail.planprojekt.dk")
smtp.Credentials = New
NetworkCredential("mail@.mail.somewhere", "password")
smtp.Send(mail)
>
bEmailSent = True
Catch ex As Exception
Exit Sub
End Try
>
>
/Snedker

0 comments:

Post a Comment