Problem with CDO.configuration

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arno R

    #1

    Problem with CDO.configuration

    Hi all,
    I am sending mail from my apps with CDO nowadays.
    However I have one client where this will not work until now.
    I am thinking this is related to the provider where the client has his internet-account.

    I am using cdosys with 'late binding'. I try to send mail with an attachment to a few mailaddresses (strTo)
    The *exact same code* (with other smtpserver-login and pw strings) does work on various other PC's with various other providers.

    The code:
    SendCDOMail "Subject... " & Format(Date, "dd-mm-yyyy"), msg, strTo, "C:\svb\output. html"

    Sub SendCDOMail(str Subject, strBody, strTo, strAttach)
    On Error GoTo Err_SendCDOMail
    Const cdoSendUsingPic kup = 1
    Const cdoSendUsingPor t = 2 'Must use this to use Delivery Notification
    Const cdoAnonymous = 0
    Const cdoBasic = 1 ' clear text
    Const cdoNTLM = 2 'NTLM
    'Delivery Status Notifications
    Const cdoDSNDefault = 0 'None
    Const cdoDSNNever = 1 'None
    Const cdoDSNFailure = 2 'Failure
    Const cdoDSNSuccess = 4 'Success
    Const cdoDSNDelay = 8 'Delay
    Const cdoDSNSuccessFa ilOrDelay = 14 'Success, failure or delay

    Dim objMsg As Object
    Dim objConf As Object
    Dim objFlds As Object

    Set objMsg = CreateObject("C DO.Message")
    Set objConf = CreateObject("C DO.Configuratio n")

    Set objFlds = objConf.Fields
    With objFlds
    .Item("http://schemas.microso ft.com/cdo/configuration/sendusing") = cdoSendUsingPor t
    .Item("http://schemas.microso ft.com/cdo/configuration/smtpserver") = "smtpserver here"
    ..Item("http://schemas.microso ft.com/cdo/configuration/smtpauthenticat e") = cdoBasic
    .Item("http://schemas.microso ft.com/cdo/configuration/sendusername") = "account here"
    .Item("http://schemas.microso ft.com/cdo/configuration/sendpassword") = "password here"
    .Update
    End With

    With objMsg
    Set .Configuration = objConf
    .To = strTo
    .Subject = strSubject
    .cc = bla@test.nl
    .From = blabla@test.nl
    .TextBody = strBody
    .AddAttachment strAttach
    .DSNOptions = cdoDSNFailure
    .Fields.Update
    .Send
    End With
    Exit Sub

    Err_SendCDOMail :
    MsgBox Err & " " & Error$, vbCritical, TITEL
    End Sub

    Thanks for any ideas...
    Arno R
  • lyle fairfield

    #2
    Re: Problem with CDO.configurati on

    "Arno R" <arracomn_o_s_p _a_m@planet.nlw rote in
    news:46717d30$0 $25501$ba620dc5 @text.nova.plan et.nl:
    Hi all,
    I am sending mail from my apps with CDO nowadays.
    However I have one client where this will not work until now.
    I am thinking this is related to the provider where the client has his
    internet-account.
    .Item("http://schemas.microso ft.com/cdo/configuration/sendusername")
    = "account here"
    .From = blabla@test.nl
    Some smtp servers seem to require that "account here" and blabla@test.nl be
    the same string. I beleve one can avoid this difficulty in general by
    omitting the the line

    ..From = blabla@test.nl

    in which case FROM will default to
    sendusername
    but it's been a long time since I wrote code that used CDO, and I may be
    recalling things that never happened.

    --
    lyle fairfield

    Comment

    • Arno R

      #3
      Re: Problem with CDO.configurati on


      "lyle fairfield" <lylefair@yahoo .caschreef in bericht news:Rtgci.1031 82$Y_.8567@read 1.cgocable.net. ..
      "Arno R" <arracomn_o_s_p _a_m@planet.nlw rote in
      news:46717d30$0 $25501$ba620dc5 @text.nova.plan et.nl:
      >Hi all,
      >I am sending mail from my apps with CDO nowadays.
      >However I have one client where this will not work until now.
      >I am thinking this is related to the provider where the client has his
      >internet-account.
      > ..Item("http://schemas.microso ft.com/cdo/configuration/sendusername")
      > = "account here"
      > .From = blabla@test.nl
      Some smtp servers seem to require that "account here" and blabla@test.nl be
      the same string. I beleve one can avoid this difficulty in general by
      omitting the the line

      .From = blabla@test.nl

      in which case FROM will default to
      sendusername
      but it's been a long time since I wrote code that used CDO, and I may be
      recalling things that never happened.

      --
      lyle fairfield
      Hi Lyle,
      How are you doing these days???

      The answer you give might be very true. I will check that tomorrow at the clients office.
      This particular ISP is very restictive indeed.

      Arno R

      Comment

      • Arno R

        #4
        Re: Problem with CDO.configurati on


        "lyle fairfield" <lylefair@yahoo .caschreef in bericht news:Rtgci.1031 82$Y_.8567@read 1.cgocable.net. ..
        "Arno R" <arracomn_o_s_p _a_m@planet.nlw rote in
        news:46717d30$0 $25501$ba620dc5 @text.nova.plan et.nl:
        >Hi all,
        >I am sending mail from my apps with CDO nowadays.
        >However I have one client where this will not work until now.
        >I am thinking this is related to the provider where the client has his
        >internet-account.
        > ..Item("http://schemas.microso ft.com/cdo/configuration/sendusername")
        > = "account here"
        > .From = blabla@test.nl
        Some smtp servers seem to require that "account here" and blabla@test.nl be
        the same string. I beleve one can avoid this difficulty in general by
        omitting the the line

        .From = blabla@test.nl

        in which case FROM will default to
        sendusername
        but it's been a long time since I wrote code that used CDO, and I may be
        recalling things that never happened.

        --
        lyle fairfield
        Hi Lyle,

        I went to the client this afternoon with a modified mde. Alas: Stil no mail sending....
        Your solution seemed very promising to me, but apparently this was/is not wat causes the problem.
        So I also mailed the techsupport at the ISP with this problem.
        I got an automated mai back like "bla bla....... very busy at the moment...... ".
        But they "will come back shortly...." Hmmm...I don't have the time to wait for that...

        Must be a 'stupid' property somewhere I guess...

        Any other ideas ?? Anyone ??
        Any free smtp-servers available ??

        Arno R

        Comment

        • Arno R

          #5
          Re: Problem with CDO.configurati on


          "lyle fairfield" <lylefair@yahoo .caschreef in bericht news:Rtgci.1031 82$Y_.8567@read 1.cgocable.net. ..
          "Arno R" <arracomn_o_s_p _a_m@planet.nlw rote in
          news:46717d30$0 $25501$ba620dc5 @text.nova.plan et.nl:
          >Hi all,
          >I am sending mail from my apps with CDO nowadays.
          >However I have one client where this will not work until now.
          >I am thinking this is related to the provider where the client has his
          >internet-account.
          > ..Item("http://schemas.microso ft.com/cdo/configuration/sendusername")
          > = "account here"
          > .From = blabla@test.nl
          Some smtp servers seem to require that "account here" and blabla@test.nl be
          the same string. I beleve one can avoid this difficulty in general by
          omitting the the line

          .From = blabla@test.nl

          in which case FROM will default to
          sendusername
          but it's been a long time since I wrote code that used CDO, and I may be
          recalling things that never happened.

          --
          lyle fairfield
          Unfortunately the above solution did not work so...
          To (try to) solve my problem I created a gmail-account and I tried to use gmail as external smtp-server.
          (I found some info o that by Googling)
          I came across the initial errormessages by using port 465 and a ssl connection like in :

          with objFields
          ....
          .Item("http://schemas.microso ft.com/cdo/configuration/smtpserverport" ) = 455
          .Item("http://schemas.microso ft.com/cdo/configuration/smtpusessl") = "true"
          end with


          BUT.... still no mail has been send ?????

          Any ideas ??
          I am at lost here !!

          Arno R

          Comment

          • John Mishefske

            #6
            Re: Problem with CDO.configurati on

            Arno R wrote:
            "lyle fairfield" <lylefair@yahoo .caschreef in bericht news:Rtgci.1031 82$Y_.8567@read 1.cgocable.net. ..
            >"Arno R" <arracomn_o_s_p _a_m@planet.nlw rote in
            >news:46717d30$ 0$25501$ba620dc 5@text.nova.pla net.nl:
            >>
            >>Hi all,
            >>I am sending mail from my apps with CDO nowadays.
            >>However I have one client where this will not work until now.
            >>I am thinking this is related to the provider where the client has his
            >>internet-account.
            >> .Item("http://schemas.microso ft.com/cdo/configuration/sendusername")
            >> = "account here"
            >> .From = blabla@test.nl
            >Some smtp servers seem to require that "account here" and blabla@test.nl be
            >the same string. I beleve one can avoid this difficulty in general by
            >omitting the the line
            >>
            >.From = blabla@test.nl
            >>
            >in which case FROM will default to
            >sendusername
            >but it's been a long time since I wrote code that used CDO, and I may be
            >recalling things that never happened.
            >>
            >--
            >lyle fairfield
            >
            Unfortunately the above solution did not work so...
            To (try to) solve my problem I created a gmail-account and I tried to use gmail as external smtp-server.
            (I found some info o that by Googling)
            I came across the initial errormessages by using port 465 and a ssl connection like in :
            >
            with objFields
            ...
            .Item("http://schemas.microso ft.com/cdo/configuration/smtpserverport" ) = 455
            .Item("http://schemas.microso ft.com/cdo/configuration/smtpusessl") = "true"
            end with
            smtpusessl takes a true/false value not a string. Here is some *working*
            code I've used. Note that some lines might wrap:

            '------------------
            ' --- CDO Defines (e.g. using GMAIL) :

            Private Const cdoSendUsingPic kup = 1 'Send message using the local SMTP
            service pickup directory.
            Private Const cdoSendUsingPor t = 2 'Send the message using the network
            (SMTP over the network).

            Private Const cdoAnonymous = 0 'Do not authenticate
            Private Const cdoBasic = 1 ' basic (clear-text) authentication
            Private Const cdoNTLM = 2 ' NTLM

            Private Const cdoMailSMTP_Ser ver As String = "smtp.gmail.com "
            Private Const cdoMailSMTP_Por t As Long = 465

            Public Function sendCDO_Mail(sT o As String, sSubject As String, sMsg As
            String) As Boolean
            On Error GoTo errHandler

            Dim objMessage As Object, sUserID As String, sPassword As String

            sUserID = Nz(DLookup("[cdoMailUserID]", "tblSetting s"), "") '
            set your user id here
            sPassword = Nz(DLookup("[cdoMailPassword]", "tblSetting s"), "") '
            set your password here

            If Len(sUserID) 0 Then
            Set objMessage = CreateObject("C DO.Message")

            With objMessage
            .Subject = sSubject
            .From = sUserID ' required field
            .To = sTo
            .TextBody = sMsg

            '==This section provides the configuration information for
            the remote SMTP server.

            ..Configuration .Fields.Item("h ttp://schemas.microso ft.com/cdo/configuration/sendusing")
            = 2

            ' Name or IP of Remote SMTP Server

            ..Configuration .Fields.Item("h ttp://schemas.microso ft.com/cdo/configuration/smtpserver")
            = cdoMailSMTP_Ser ver

            ' Type of authentication, NONE, Basic (Base64 encoded), NTLM

            ..Configuration .Fields.Item("h ttp://schemas.microso ft.com/cdo/configuration/smtpauthenticat e")
            = cdoBasic

            ' Your UserID on the SMTP server

            ..Configuration .Fields.Item("h ttp://schemas.microso ft.com/cdo/configuration/sendusername")
            = sUserID

            ' Your password on the SMTP server

            ..Configuration .Fields.Item("h ttp://schemas.microso ft.com/cdo/configuration/sendpassword")
            = sPassword

            ' Server port (typically 25) - gmail uses 587 or 465

            ..Configuration .Fields.Item("h ttp://schemas.microso ft.com/cdo/configuration/smtpserverport" )
            = cdoMailSMTP_Por t

            ' Use SSL for the connection (False or True)

            ..Configuration .Fields.Item("h ttp://schemas.microso ft.com/cdo/configuration/smtpusessl")
            = True

            'Connection Timeout in seconds (the maximum time CDO will
            try to establish a connection to the SMTP server)

            ..Configuration .Fields.Item("h ttp://schemas.microso ft.com/cdo/configuration/smtpconnectiont imeout")
            = 180

            .Configuration. Fields.Update
            '==End remote SMTP server configuration section==

            .Send

            sendCDO_Mail = True
            End With
            End If

            Exit Function

            errHandler:

            Dim nErr As Long, sErr As String
            nErr = Err.Number
            sErr = Err.Description

            Debug.Print "Error in sendCDO_Mail: " & nErr & " - " & sErr

            End Function
            '------------------------

            Good luck!

            --
            '--------------------------
            ' John Mishefske
            ' UtterAccess Editor
            ' 2007 Microsoft Access MVP
            '--------------------------

            Comment

            • Arno R

              #7
              Re: Problem with CDO.configurati on

              Hi John,

              Thanks a million for your code !!
              Because of that code I was able to figure out what was wrong in my code.
              smtpusessl takes a true/false value not a string. Here is some *working*
              code I've used. Note that some lines might wrap:
              Indeed "true" should not be a string but should be the value 'True'.
              It actually was the value True, because I was using code like MailOption("SSL ") for that option which was returning a boolean value.
              For simplicity reasons I posted 'wrong' code.... :-(

              But your code worked, and mine did not, so I was able to find the offending code!
              What was wrong?
              It appeared that the line .DSNOptions = cdoDSNFailure (or ..DSNOptions = 2) was causing the trouble!
              When I omitted that line everything was OK.
              Including this line (also in your code) results in mail not being delivered.

              So problem solved !
              Thanks again!

              Arno R

              Comment

              • John Mishefske

                #8
                Re: Problem with CDO.configurati on

                Arno R wrote:
                Hi John,
                >
                Thanks a million for your code !!
                Because of that code I was able to figure out what was wrong in my code.
                Glad I could help.
                It appeared that the line .DSNOptions = cdoDSNFailure (or .DSNOptions = 2) was causing the trouble!
                When I omitted that line everything was OK.
                That is for Delivery Status Notification. Here is some additional info
                if readers are interested:




                --
                '--------------------------
                ' John Mishefske
                ' UtterAccess Editor
                ' 2007 Microsoft Access MVP
                '--------------------------

                Comment

                Working...