unable to relay with vb.net system.mail

Discussion in 'ASP .Net' started by Chris Thunell, Dec 9, 2004.

  1. I am using the following code to send email out in a vb.net web program
    through an exchange 2003 server. My web server is on a separate server.
    When i try to send email inside the office, it works fine... but when i try
    to send email outside the company i get "unable to relay" error message.
    Please look at the code, i don't see a way to send username and password
    credentials to allow the relaying to occur (I don't want unauthenticated
    relaying to be allowed, because that would open our system up for outsiders
    to relay as well). Both the web server and exchange are within our
    organzation. Any thoughts?
    Thanks in advance!
    Chris Thunell

    Imports System.Web

    Imports System.Web.Mail


    Dim message As New MailMessage

    Dim Attachment As System.Web.Mail.MailAttachment

    With message

    ..BodyFormat = MailFormat.Html

    ..To = "" 'RecipientList

    ..Cc = MessageFrom

    ..Subject = MessageSubject

    ..From = MessageFrom

    ..Body = MessageBody

    If Len(Trim(AttachmentLocation)) > 1 Then

    Attachment = New MailAttachment(Trim(AttachmentLocation))

    ..Attachments.Add(Attachment)

    End If

    End With

    SmtpMail.SmtpServer = "myemailserver.domain.com"

    SmtpMail.Send(message)
    Chris Thunell, Dec 9, 2004
    #1
    1. Advertising

  2. There doesn't look to be anything wrong with your code, so your mail admin
    should be able to set a rule in your mail server to allow relays from the
    web servers IP address without compromising the ability to stop relays from
    outside the company

    --
    Regards

    John Timney
    ASP.NET MVP
    Microsoft Regional Director

    "Chris Thunell" <> wrote in message
    news:%...
    > I am using the following code to send email out in a vb.net web program
    > through an exchange 2003 server. My web server is on a separate server.
    > When i try to send email inside the office, it works fine... but when i

    try
    > to send email outside the company i get "unable to relay" error message.
    > Please look at the code, i don't see a way to send username and password
    > credentials to allow the relaying to occur (I don't want unauthenticated
    > relaying to be allowed, because that would open our system up for

    outsiders
    > to relay as well). Both the web server and exchange are within our
    > organzation. Any thoughts?
    > Thanks in advance!
    > Chris Thunell
    >
    > Imports System.Web
    >
    > Imports System.Web.Mail
    >
    >
    > Dim message As New MailMessage
    >
    > Dim Attachment As System.Web.Mail.MailAttachment
    >
    > With message
    >
    > .BodyFormat = MailFormat.Html
    >
    > .To = "" 'RecipientList
    >
    > .Cc = MessageFrom
    >
    > .Subject = MessageSubject
    >
    > .From = MessageFrom
    >
    > .Body = MessageBody
    >
    > If Len(Trim(AttachmentLocation)) > 1 Then
    >
    > Attachment = New MailAttachment(Trim(AttachmentLocation))
    >
    > .Attachments.Add(Attachment)
    >
    > End If
    >
    > End With
    >
    > SmtpMail.SmtpServer = "myemailserver.domain.com"
    >
    > SmtpMail.Send(message)
    >
    >
    John Timney \(ASP.NET MVP\), Dec 9, 2004
    #2
    1. Advertising

  3. Do you have a Microsoft article that tells me how to do that?
    Chris Thunell


    "John Timney (ASP.NET MVP)" <> wrote in message
    news:...
    > There doesn't look to be anything wrong with your code, so your mail admin
    > should be able to set a rule in your mail server to allow relays from the
    > web servers IP address without compromising the ability to stop relays

    from
    > outside the company
    >
    > --
    > Regards
    >
    > John Timney
    > ASP.NET MVP
    > Microsoft Regional Director
    >
    > "Chris Thunell" <> wrote in message
    > news:%...
    > > I am using the following code to send email out in a vb.net web program
    > > through an exchange 2003 server. My web server is on a separate server.
    > > When i try to send email inside the office, it works fine... but when i

    > try
    > > to send email outside the company i get "unable to relay" error message.
    > > Please look at the code, i don't see a way to send username and password
    > > credentials to allow the relaying to occur (I don't want unauthenticated
    > > relaying to be allowed, because that would open our system up for

    > outsiders
    > > to relay as well). Both the web server and exchange are within our
    > > organzation. Any thoughts?
    > > Thanks in advance!
    > > Chris Thunell
    > >
    > > Imports System.Web
    > >
    > > Imports System.Web.Mail
    > >
    > >
    > > Dim message As New MailMessage
    > >
    > > Dim Attachment As System.Web.Mail.MailAttachment
    > >
    > > With message
    > >
    > > .BodyFormat = MailFormat.Html
    > >
    > > .To = "" 'RecipientList
    > >
    > > .Cc = MessageFrom
    > >
    > > .Subject = MessageSubject
    > >
    > > .From = MessageFrom
    > >
    > > .Body = MessageBody
    > >
    > > If Len(Trim(AttachmentLocation)) > 1 Then
    > >
    > > Attachment = New MailAttachment(Trim(AttachmentLocation))
    > >
    > > .Attachments.Add(Attachment)
    > >
    > > End If
    > >
    > > End With
    > >
    > > SmtpMail.SmtpServer = "myemailserver.domain.com"
    > >
    > > SmtpMail.Send(message)
    > >
    > >

    >
    >
    Chris Thunell, Dec 9, 2004
    #3
  4. Chris,
    I've run into this exact issue, and it is indeed the mail server's
    settings. If your mail server is IIS, check out any of the articles
    returned by this simple google search:
    http://www.google.com/search?sourceid=navclient&ie=UTF-8&q=set relay security mail IIS

    Regardless, this is a mail server issue, not ASP.NET.

    --
    Best regards,
    Jeffrey Palermo
    Blog: http://dotnetjunkies.com/weblog/jpalermo


    "Chris Thunell" <> wrote in message
    news:OFrJr$...
    > Do you have a Microsoft article that tells me how to do that?
    > Chris Thunell
    >
    >
    > "John Timney (ASP.NET MVP)" <> wrote in message
    > news:...
    > > There doesn't look to be anything wrong with your code, so your mail

    admin
    > > should be able to set a rule in your mail server to allow relays from

    the
    > > web servers IP address without compromising the ability to stop relays

    > from
    > > outside the company
    > >
    > > --
    > > Regards
    > >
    > > John Timney
    > > ASP.NET MVP
    > > Microsoft Regional Director
    > >
    > > "Chris Thunell" <> wrote in message
    > > news:%...
    > > > I am using the following code to send email out in a vb.net web

    program
    > > > through an exchange 2003 server. My web server is on a separate

    server.
    > > > When i try to send email inside the office, it works fine... but when

    i
    > > try
    > > > to send email outside the company i get "unable to relay" error

    message.
    > > > Please look at the code, i don't see a way to send username and

    password
    > > > credentials to allow the relaying to occur (I don't want

    unauthenticated
    > > > relaying to be allowed, because that would open our system up for

    > > outsiders
    > > > to relay as well). Both the web server and exchange are within our
    > > > organzation. Any thoughts?
    > > > Thanks in advance!
    > > > Chris Thunell
    > > >
    > > > Imports System.Web
    > > >
    > > > Imports System.Web.Mail
    > > >
    > > >
    > > > Dim message As New MailMessage
    > > >
    > > > Dim Attachment As System.Web.Mail.MailAttachment
    > > >
    > > > With message
    > > >
    > > > .BodyFormat = MailFormat.Html
    > > >
    > > > .To = "" 'RecipientList
    > > >
    > > > .Cc = MessageFrom
    > > >
    > > > .Subject = MessageSubject
    > > >
    > > > .From = MessageFrom
    > > >
    > > > .Body = MessageBody
    > > >
    > > > If Len(Trim(AttachmentLocation)) > 1 Then
    > > >
    > > > Attachment = New MailAttachment(Trim(AttachmentLocation))
    > > >
    > > > .Attachments.Add(Attachment)
    > > >
    > > > End If
    > > >
    > > > End With
    > > >
    > > > SmtpMail.SmtpServer = "myemailserver.domain.com"
    > > >
    > > > SmtpMail.Send(message)
    > > >
    > > >

    > >
    > >

    >
    >
    Jeffrey Palermo [MCP], Dec 10, 2004
    #4
    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. Jinsong Liu
    Replies:
    2
    Views:
    399
    Jinsong Liu
    Sep 10, 2004
  2. Rico
    Replies:
    12
    Views:
    14,918
    slaguila
    Jun 9, 2011
  3. Benedict Verheyen

    smtplib problem, Unable to relay for

    Benedict Verheyen, Dec 21, 2007, in forum: Python
    Replies:
    2
    Views:
    2,046
    Dennis Lee Bieber
    Dec 22, 2007
  4. rose

    Relay Error in Send Mail in 2.0

    rose, Mar 31, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    278
  5. Tim::..

    HELP.. ERROR: Unable to relay for

    Tim::.., Jun 22, 2004, in forum: ASP General
    Replies:
    2
    Views:
    343
    Chris Barber
    Jun 23, 2004
Loading...

Share This Page