ASP.NET mail error: The transport failed to connect to the server

Discussion in 'ASP .Net' started by James Lankford, Nov 13, 2003.

  1. Hello group:

    I have reached the end of my rope with this error. I have pretty much tried every suggestion I've found thus far and I
    get this error no matter what I do. I did try using the CDOSYS test from Microsoft as a test for the smtpserver, and it'll send that way.
    Here's my existing code:

    Public Sub SendMail()

    Dim myMailMsg As New Mail.MailMessage()

    With myMailMsg
    .To = "<Send to address">
    .From = <"Send From Address">
    .Subject = "Test message"
    .Body = "This is a test."
    .BodyFormat = Mail.MailFormat.Text
    End With

    Mail.SmtpMail.SmtpServer = "<smtp server>"
    Mail.SmtpMail.Send(myMailMsg)

    End Sub

    For my SmtpServer, I've used localhost, smarthost, the actual value of our corporate smtp server address - nothing changes. I always get that
    error message.

    I have modifed the machine.config file, given the ASP.NET user process admin (temp) access, assigned the machine id of 127.0.0.1 to the Access tab for the relay settings, and every other suggestion I've found - nothing at all seems to make any change. I'm using Windows Server 2003.

    Can someone please help me? I don't know what else to do.

    Thanks,

    James Lankford
    James Lankford, Nov 13, 2003
    #1
    1. Advertising

  2. i too faced a similar problem once.

    it turned out that my mail server required that the sender be on the same domain as the smtp server.
    eg: if my smtp server is "mail.abc.com"... then the sender has to be .

    just see if this applies to you as well.

    regards,
    Nauzad Kapadia
    "James Lankford" <> wrote in message news:...
    Hello group:

    I have reached the end of my rope with this error. I have pretty much tried every suggestion I've found thus far and I
    get this error no matter what I do. I did try using the CDOSYS test from Microsoft as a test for the smtpserver, and it'll send that way.
    Here's my existing code:

    Public Sub SendMail()

    Dim myMailMsg As New Mail.MailMessage()

    With myMailMsg
    .To = "<Send to address">
    .From = <"Send From Address">
    .Subject = "Test message"
    .Body = "This is a test."
    .BodyFormat = Mail.MailFormat.Text
    End With

    Mail.SmtpMail.SmtpServer = "<smtp server>"
    Mail.SmtpMail.Send(myMailMsg)

    End Sub

    For my SmtpServer, I've used localhost, smarthost, the actual value of our corporate smtp server address - nothing changes. I always get that
    error message.

    I have modifed the machine.config file, given the ASP.NET user process admin (temp) access, assigned the machine id of 127.0.0.1 to the Access tab for the relay settings, and every other suggestion I've found - nothing at all seems to make any change. I'm using Windows Server 2003.

    Can someone please help me? I don't know what else to do.

    Thanks,

    James Lankford
    Nauzad Kapadia, Nov 13, 2003
    #2
    1. Advertising

  3. James Lankford

    thropde Guest

    just comment smtpserver name line
    (>Mail.SmtpMail.SmtpServer = "<smtp server>") and try.
    In .Net 1.1 this property assigned to local machine by
    default, for 1.0 give proper name of the machine.
    windows 2003 runs under .net 1.1
    it worked for me!
    hope this will help.

    bye

    >-----Original Message-----
    >Hello group:
    >
    >I have reached the end of my rope with this error. I have

    pretty much tried every suggestion I've found thus far and
    I
    >get this error no matter what I do. I did try using the

    CDOSYS test from Microsoft as a test for the smtpserver,
    and it'll send that way.
    >Here's my existing code:
    >
    >Public Sub SendMail()
    >
    > Dim myMailMsg As New Mail.MailMessage()
    >
    > With myMailMsg
    > .To = "<Send to address">
    > .From = <"Send From Address">
    > .Subject = "Test message"
    > .Body = "This is a test."
    > .BodyFormat = Mail.MailFormat.Text
    > End With
    >
    >Mail.SmtpMail.SmtpServer = "<smtp server>"
    > Mail.SmtpMail.Send(myMailMsg)
    >
    > End Sub
    >
    >For my SmtpServer, I've used localhost, smarthost, the

    actual value of our corporate smtp server address -
    nothing changes. I always get that
    >error message.
    >
    >I have modifed the machine.config file, given the ASP.NET

    user process admin (temp) access, assigned the machine id
    of 127.0.0.1 to the Access tab for the relay settings, and
    every other suggestion I've found - nothing at all seems
    to make any change. I'm using Windows Server 2003.
    >
    >Can someone please help me? I don't know what else to do.
    >
    >Thanks,
    >
    >James Lankford
    >
    >
    thropde, Nov 13, 2003
    #3
  4. I don't think I can really do that though, because the server is not the
    smtp server, we are using a corporate server. If I remove that line, then
    the code will "assume" the local box is the smtpserver. Anyway, I had
    already tried that, but it doesn't make any difference either.

    --
    James Lankford

    "thropde" <> wrote in message
    news:034101c3a9c6$70d630d0$...
    > just comment smtpserver name line
    > (>Mail.SmtpMail.SmtpServer = "<smtp server>") and try.
    > In .Net 1.1 this property assigned to local machine by
    > default, for 1.0 give proper name of the machine.
    > windows 2003 runs under .net 1.1
    > it worked for me!
    > hope this will help.
    >
    > bye
    >
    > >-----Original Message-----
    > >Hello group:
    > >
    > >I have reached the end of my rope with this error. I have

    > pretty much tried every suggestion I've found thus far and
    > I
    > >get this error no matter what I do. I did try using the

    > CDOSYS test from Microsoft as a test for the smtpserver,
    > and it'll send that way.
    > >Here's my existing code:
    > >
    > >Public Sub SendMail()
    > >
    > > Dim myMailMsg As New Mail.MailMessage()
    > >
    > > With myMailMsg
    > > .To = "<Send to address">
    > > .From = <"Send From Address">
    > > .Subject = "Test message"
    > > .Body = "This is a test."
    > > .BodyFormat = Mail.MailFormat.Text
    > > End With
    > >
    > >Mail.SmtpMail.SmtpServer = "<smtp server>"
    > > Mail.SmtpMail.Send(myMailMsg)
    > >
    > > End Sub
    > >
    > >For my SmtpServer, I've used localhost, smarthost, the

    > actual value of our corporate smtp server address -
    > nothing changes. I always get that
    > >error message.
    > >
    > >I have modifed the machine.config file, given the ASP.NET

    > user process admin (temp) access, assigned the machine id
    > of 127.0.0.1 to the Access tab for the relay settings, and
    > every other suggestion I've found - nothing at all seems
    > to make any change. I'm using Windows Server 2003.
    > >
    > >Can someone please help me? I don't know what else to do.
    > >
    > >Thanks,
    > >
    > >James Lankford
    > >
    > >
    James Lankford, Nov 13, 2003
    #4
  5. The box I'm trying this on is not directly on the domain on as the SMTP server, but it is trusted by that server. In addition, I had to request that box be added to the list of the SMTP server to be allowed to relay through it. I will look into this and see if it affects my situation.

    Thanks,

    --
    James Lankford
    "Nauzad Kapadia" <> wrote in message news:...
    i too faced a similar problem once.

    it turned out that my mail server required that the sender be on the same domain as the smtp server.
    eg: if my smtp server is "mail.abc.com"... then the sender has to be .

    just see if this applies to you as well.

    regards,
    Nauzad Kapadia
    "James Lankford" <> wrote in message news:...
    Hello group:

    I have reached the end of my rope with this error. I have pretty much tried every suggestion I've found thus far and I
    get this error no matter what I do. I did try using the CDOSYS test from Microsoft as a test for the smtpserver, and it'll send that way.
    Here's my existing code:

    Public Sub SendMail()

    Dim myMailMsg As New Mail.MailMessage()

    With myMailMsg
    .To = "<Send to address">
    .From = <"Send From Address">
    .Subject = "Test message"
    .Body = "This is a test."
    .BodyFormat = Mail.MailFormat.Text
    End With

    Mail.SmtpMail.SmtpServer = "<smtp server>"
    Mail.SmtpMail.Send(myMailMsg)

    End Sub

    For my SmtpServer, I've used localhost, smarthost, the actual value of our corporate smtp server address - nothing changes. I always get that
    error message.

    I have modifed the machine.config file, given the ASP.NET user process admin (temp) access, assigned the machine id of 127.0.0.1 to the Access tab for the relay settings, and every other suggestion I've found - nothing at all seems to make any change. I'm using Windows Server 2003.

    Can someone please help me? I don't know what else to do.

    Thanks,

    James Lankford
    James Lankford, Nov 13, 2003
    #5
  6. Hi James,

    Firstly I want to thank all the people who provided help in this issue.

    To isolate the root cause of this issue, I suggest that we test the
    following console sample. Can you reproduce the same error?

    HOWTO: Send E-mail Programmatically with System.Web.Mail and Visual Basic
    ..NET
    http://support.microsoft.com/?id=314201

    If I have misunderstood your concern, please feel free to let me know.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Nov 14, 2003
    #6
  7. Jacob,

    Thanks again for your help. By using the example you gave via
    Microsoft's knowledge site, I found (I think) what the problem was, although
    the error message was confusing. I dropped in the code from the article
    below, and it worked - absolutely no problem. But then I realized that the
    code from that example was practically identical to mine.......except mainly
    for one line.

    In my declaration, I used:
    Dim myMailMsg As New MailMessage()

    In your example, the code used:
    Dim oMsg As MailMessage = New MailMessage()

    The difference was that I did not declare the variable type first, I was
    just setting my variable equal to a new instance of the MailMessage Class
    without declaring it "as" a MailMessage type variable.

    What is strange, is that my original code worked on a Windows 2000 server,
    but it did not on Windows 2003 Server, with both running the .NET Framework
    version 1.1. The error would occur when the Send method was called on the
    Mail.SmtpMail class.

    I guess the error message was confusing because I normally am used to seeing
    some sort of "object reference not set to an instance of an object" type
    error.

    Thoughts?

    --
    James Lankford


    "Jacob Yang [MSFT]" <> wrote in message
    news:...
    > Hi James,
    >
    > Firstly I want to thank all the people who provided help in this issue.
    >
    > To isolate the root cause of this issue, I suggest that we test the
    > following console sample. Can you reproduce the same error?
    >
    > HOWTO: Send E-mail Programmatically with System.Web.Mail and Visual Basic
    > .NET
    > http://support.microsoft.com/?id=314201
    >
    > If I have misunderstood your concern, please feel free to let me know.
    >
    > Best regards,
    >
    > Jacob Yang
    > Microsoft Online Partner Support
    > Get Secure! ¨C www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
    James Lankford, Nov 14, 2003
    #7
  8. Hi James,

    Thank you for your update. I am very glad to know that the original problem
    is resolved.

    As I understand, now you want to know why the error message is "The
    transport failed to connect to the server". You think that it should be
    something like "object reference not set to an instance of an object". Is
    it correct?

    If I have misunderstood your concern, please feel free to let me know.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Nov 17, 2003
    #8
  9. Hi Jacob,

    Yes, That is correct. It seems like I wasted alot of time trying to
    troubleshoot a problem - my own fault, that is - at the expense of a
    mis-leading error message.


    James Lankford



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    James Lankford, Nov 17, 2003
    #9
  10. Hi James,

    Thank you for your update.

    I have done a lot of research regarding this issue but I cannot reproduce
    the error on my side.

    That is to say, the following statement works on my side. (The "()" will be
    removed by the VS.NET 2003 IDE automatically.)

    Dim oMsg As New MailMessage

    The following is my testing code. Please try it on your side.
    ----------------------------------------------------------------------------
    -----------
    Imports System.Web.Mail

    Module Module1


    Sub Main()

    'Dim oMsg As MailMessage = New MailMessage

    Dim oMsg As New MailMessage
    ' TODO: Replace with sender e-mail address.
    oMsg.From = ""
    ' TODO: Replace with recipient e-mail address.
    oMsg.To = ""
    oMsg.Subject = "Send using Web Mail"

    ' SEND IN HTML FORMAT (comment this line to send plain text).
    oMsg.BodyFormat = MailFormat.Html

    'HTML Body (remove HTML tags for plain text).
    oMsg.Body = "<HTML><BODY><B>Hello World!</B></BODY></HTML>"

    ' ADD AN ATTACHMENT.
    ' TODO: Replace with path to attachment.
    ' Dim sFile As String = "C:\temp\Hello.txt"
    ' Dim oAttch As MailAttachment = New MailAttachment(sFile,
    MailEncoding.Base64)
    '
    ' oMsg.Attachments.Add(oAttch)

    ' TODO: Replace with the name of your remote SMTP server.
    SmtpMail.SmtpServer = "smarthost"
    SmtpMail.Send(oMsg)

    oMsg = Nothing
    ' oAttch = Nothing
    End Sub

    End Module
    ------------------------------------------------------

    If I have misunderstood your concern, please feel free to let me know.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Nov 19, 2003
    #10
  11. James Lankford, Nov 19, 2003
    #11
  12. Hi James,

    Thank you for your update but I cannot see the content of your post. It is
    empty.

    Would you please repost it? I certainly appreciate your time.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Nov 20, 2003
    #12
  13. James Lankford

    John Yu Guest

    Hi,

    I have been getting this error for some time now. What is getting
    strange is that:
    1. The same code works on our dev and prod servers but not on my
    workstation;
    2. The code sample from Microsoft's site works on my workstation.

    What IS the real problem here?

    Thanks a lot,

    John





    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    John Yu, Nov 10, 2004
    #13
  14. James Lankford

    naveenkumarmandava

    Joined:
    Jul 16, 2008
    Messages:
    2
    Transportation error in sending email

    Helo all I am using below code but i am facing an error like tranportation error in sending an email please help me out ...

    sch = "http://schemas.microsoft.com/cdo/configuration/"
    cdoConfig = CreateObject("CDO.Configuration")
    With cdoConfig.Fields
    .Item(sch & "sendusing") = 2 ' cdoSendUsingPort
    .Item(sch & "smtpserver") = "<mailexchanger.state.sd.us>"
    .update()
    End With
    MyMail = CreateObject("CDO.Message")
    'cdoMessage = CreateObject("CDO.Message")

    With MyMail
    .Configuration = cdoConfig
    .From = ""
    .To = ""
    .Subject = "Sample CDO Message"
    .TextBody = "This is a test for CDO.message"
    .Send()
    End With

    MyMail = Nothing
    cdoConfig = Nothing
    naveenkumarmandava, Jul 16, 2008
    #14
  15. James Lankford

    naveenkumarmandava

    Joined:
    Jul 16, 2008
    Messages:
    2
    Email not reciving to the admin ...when using the domain address..

    helo all

    When I am using this code with my domain mail ids email is not going but when i use emails like gamil or others its working pretty good..what may be reason please help me out....

    Dim strResults As String
    'Put user code to initialize the page here
    Dim msg As New MailMessage
    ' TO: can be a semicolon separated list of email addresses
    'msg.To = strRecip & ";"
    msg.To = strTo
    'msg.Bcc = ";"
    msg.Bcc = ";"
    msg.From = strFrom
    msg.Subject = strSubject
    msg.BodyFormat = MailFormat.Html '.text or .html
    msg.Body = strBody
    msg.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    msg.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailexchanger.state.sd.us"
    msg.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    SmtpMail.SmtpServer.Insert(0, " mailexchanger.state.sd.us")

    Try
    SmtpMail.Send(msg)
    strResults = "Message sent to " & strTo & " at: " & Date.Now & "."
    Return strResults
    Catch ex As Exception
    strResults = "Can't send message cuz: " & ex.Message
    Return strResults
    End Try

    msg = Nothing
    naveenkumarmandava, Jul 16, 2008
    #15
    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. Lori McDonald
    Replies:
    0
    Views:
    5,724
    Lori McDonald
    Feb 16, 2004
  2. Sudhan
    Replies:
    1
    Views:
    7,711
    Teemu Keiski
    Dec 20, 2005
  3. =?Utf-8?B?bmJpc3NldHRl?=
    Replies:
    1
    Views:
    3,532
    jcallinan
    Oct 2, 2006
  4. Hawksey
    Replies:
    1
    Views:
    887
    rajanand_m
    Nov 6, 2009
  5. Nathan Sokalski
    Replies:
    5
    Views:
    585
    Ricky Yau
    Dec 11, 2006
Loading...

Share This Page