Trouble sending email with ASP.NET 2.0

Discussion in 'ASP .Net' started by Nathan Sokalski, Jan 5, 2007.

  1. 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: :
    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

    http://www.nathansokalski.com/
    Nathan Sokalski, Jan 5, 2007
    #1
    1. Advertising

  2. On Fri, 5 Jan 2007 03:55:44 -0500, "Nathan Sokalski"
    <> 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("",
    "Subject")
    mail.To.Add("")

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

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

    bEmailSent = True
    Catch ex As Exception
    Exit Sub
    End Try


    /Snedker
    Morten Snedker, Jan 5, 2007
    #2
    1. Advertising

  3. 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("")
    confirmation.To.Add("")
    confirmation.Subject = "My Subject"
    confirmation.Body = "My Body"

    confsender.Send(confirmation)
    End Sub


    Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    "Morten Snedker" <morten_spammenot_ATdbconsult.dk> wrote in message
    news:...
    > On Fri, 5 Jan 2007 03:55:44 -0500, "Nathan Sokalski"
    > <> 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("",
    > "Subject")
    > mail.To.Add("")
    >
    > mail.Subject = "Subject"
    > mail.Body = "Body"
    >
    > Dim smtp As New Mail.SmtpClient("mail.planprojekt.dk")
    > smtp.Credentials = New
    > NetworkCredential("", "password")
    > smtp.Send(mail)
    >
    > bEmailSent = True
    > Catch ex As Exception
    > Exit Sub
    > End Try
    >
    >
    > /Snedker
    Nathan Sokalski, Jan 5, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. khawar
    Replies:
    0
    Views:
    785
    khawar
    Oct 30, 2003
  2. =?Utf-8?B?S2VubmV0aCBQ?=

    Trouble w sending email

    =?Utf-8?B?S2VubmV0aCBQ?=, Aug 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    417
  3. Luke
    Replies:
    2
    Views:
    4,705
    Nigel Wade
    Mar 15, 2007
  4. rote
    Replies:
    8
    Views:
    766
  5. Replies:
    2
    Views:
    97
    Gunnar Hjalmarsson
    Jan 31, 2006
Loading...

Share This Page