Trouble sending email with ASP.NET 2.0

  • Thread starter Nathan Sokalski
  • Start date
N

Nathan Sokalski

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: (e-mail address removed):
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.
 
M

Morten Snedker

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("(e-mail address removed)",
"Subject")
mail.To.Add("(e-mail address removed)")

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

Dim smtp As New Mail.SmtpClient("mail.planprojekt.dk")
smtp.Credentials = New
NetworkCredential("(e-mail address removed)", "password")
smtp.Send(mail)

bEmailSent = True
Catch ex As Exception
Exit Sub
End Try


/Snedker
 
N

Nathan Sokalski

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("(e-mail address removed)")
confirmation.To.Add("(e-mail address removed)")
confirmation.Subject = "My Subject"
confirmation.Body = "My Body"

confsender.Send(confirmation)
End Sub


Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top