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.com> wrote:

> 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
If you are using the machine's local SMTP Service,
you may need to add a Smarthost or domains (e.g., "*.com", "*.net")
so that email sent through it is allowed to be sent out or relayed.
Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Nathan Sokalski" wrote:

> 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@.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 viewer
s
> 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 th
e
> 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@.hotmail.com
> http://www.nathansokalski.com/
>
>
The code I am using is as follows:
Private Sub SendEmailNotification()
Dim confsender As New
SmtpClient(System.Configuration.ConfigurationManager.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.dk> wrote in message
news:2p6sp2dqb6qkfg0j60i3gt12iqvhdgcj70@.
4ax.com...
> On Fri, 5 Jan 2007 03:55:44 -0500, "Nathan Sokalski"
> <njsokalski@.hotmail.com> wrote:
>
> 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