+ Reply to Thread
Results 1 to 2 of 2

How 2 remove this error - SMTP Server, Email using CDO

  1. #1
    Yongjun CHEN
    Guest

    How 2 remove this error - SMTP Server, Email using CDO

    I stole the following code from Ron De Bruin's website with
    minor modification.
    The SMTP server name "smtp.sbcglobal.yahoo.com" is from my
    ISP.
    The SMTP server name is the same as I set up my outlook
    express outgoing mail and which works fine.
    When I tried to execute the following code, the got the
    following error message:

    ------------------------------------------------
    Run-time error '-2147220975(80040211)'
    The message could not be sent to the SMTP server.
    The transport error code was 0x80040217.
    The server response is not available.
    ------------------------------------------------

    Any suggestion to remove the error message?
    Thanks a lot.

    Yongjun CHEN

    Houston, TX
    U.S.A

    P.S. My outlook express (using same account and SMTP
    server) works fine.

    ========= CODE ========= CODE =========
    Sub SendEmail()
    Dim iMsg As Object
    Dim iConf As Object
    Dim Flds As Variant

    Application.ScreenUpdating = False
    Set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.Configuration")

    iConf.Load -1 ' CDO Source Defaults
    Set Flds = iConf.Fields

    With Flds

    ..Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
    = 2

    ..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
    = "smtp.sbcglobal.yahoo.com"

    ..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
    = 25
    .Update
    End With

    With iMsg
    Set .Configuration = iConf
    .To = "someone@hotmail.com"
    .CC = ""
    .BCC = ""
    .From = """ABC ZZZ"" <ABC.ZZZ@sbcglobal.net>"
    .Subject = "This is a test"
    .TextBody = "Hi there"
    '.AddAttachment "C:/" & WBname
    ' You can add any file you want with this line
    ..AddAttachment "C:/Test.txt"
    .Send
    End With

    Set iMsg = Nothing
    Set iConf = Nothing
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Ron de Bruin
    Guest

    Re: How 2 remove this error - SMTP Server, Email using CDO

    Yongjun

    http://www.rondebruin.nl/cdo.htm
    If you not use the comented code in the macro's it will use the settings from Outlook express
    Try this first


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl



    "Yongjun CHEN" <yjdchen@hotmail.com> wrote in message news:04ae01c515cf$4d178dd0$a501280a@phx.gbl...
    >I stole the following code from Ron De Bruin's website with
    > minor modification.
    > The SMTP server name "smtp.sbcglobal.yahoo.com" is from my
    > ISP.
    > The SMTP server name is the same as I set up my outlook
    > express outgoing mail and which works fine.
    > When I tried to execute the following code, the got the
    > following error message:
    >
    > ------------------------------------------------
    > Run-time error '-2147220975(80040211)'
    > The message could not be sent to the SMTP server.
    > The transport error code was 0x80040217.
    > The server response is not available.
    > ------------------------------------------------
    >
    > Any suggestion to remove the error message?
    > Thanks a lot.
    >
    > Yongjun CHEN
    >
    > Houston, TX
    > U.S.A
    >
    > P.S. My outlook express (using same account and SMTP
    > server) works fine.
    >
    > ========= CODE ========= CODE =========
    > Sub SendEmail()
    > Dim iMsg As Object
    > Dim iConf As Object
    > Dim Flds As Variant
    >
    > Application.ScreenUpdating = False
    > Set iMsg = CreateObject("CDO.Message")
    > Set iConf = CreateObject("CDO.Configuration")
    >
    > iConf.Load -1 ' CDO Source Defaults
    > Set Flds = iConf.Fields
    >
    > With Flds
    >
    > .Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
    > = 2
    >
    > .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
    > = "smtp.sbcglobal.yahoo.com"
    >
    > .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
    > = 25
    > .Update
    > End With
    >
    > With iMsg
    > Set .Configuration = iConf
    > .To = "someone@hotmail.com"
    > .CC = ""
    > .BCC = ""
    > .From = """ABC ZZZ"" <ABC.ZZZ@sbcglobal.net>"
    > .Subject = "This is a test"
    > .TextBody = "Hi there"
    > '.AddAttachment "C:/" & WBname
    > ' You can add any file you want with this line
    > .AddAttachment "C:/Test.txt"
    > .Send
    > End With
    >
    > Set iMsg = Nothing
    > Set iConf = Nothing
    > Application.ScreenUpdating = True
    > End Sub




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1