Results 1 to 13 of 13

Thread: [RESOLVED] CDO.Message not working in Win7.64bit

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Location
    Far East
    Posts
    232

    Resolved [RESOLVED] CDO.Message not working in Win7.64bit

    Hi members

    Though this forum i had just been able to use "Ms CDO for Exchange 2000 Libary" to send email via gmail STMP server in PC's running XPWin.sp2-3. This is done after CreateObject("CDO.Configuration") with all the appropriate Fields referring to "http://schemas.microsoft.com/cdo/configuration/" followed by object CDO.Message .send.

    However when i do exactly the same thing in Win7.64bit, error message "From or Sender Field missing" at the point of .send. There was no error in .Update of Configuration.

    The difference i note is the reference in made to C:\windows\sysWOW64\CDOEX.DLL which is however exactly the same as that found in WinXp.

    I had search the web and is unable to find a solution. Again need help from my senior peers. Thanks.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: CDO.Message not working in Win7.64bit

    default values that may have been valid in xp systems, may need to be specified in win7, as there is no inbuilt mail client
    have you assigned values to the from or sender fields?

    as we do not see your code hard to guess

    gmail does not allow spoofing of the senders email address, it will always be forwarded as [email protected]
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Location
    Far East
    Posts
    232

    Re: CDO.Message not working in Win7.64bit

    Thanks West

    The codes i use that work in XPWin.sp3 but failed in win7.64bit are as follows:

    Dim MsSchm$, Cd0Conf as object, CdoMsg as object

    MsSchm$ = "http://schemas.microsoft.com/cdo/configuration/"

    Set Cd0Conf = CreateObject("CDO.Configuration")
    With Cd0Conf.Fields
    .Item(MsSchm$ & "smtpauthenticate") = 1
    .Item(MsSchm$ & "smtpusessl") = True
    .Item(MsSchm$ & "smtpserver") = "smtp.gmail.com"
    .Item(MsSchm$ & "sendusername") = "[email protected]"
    .Item(MsSchm$ & "sendpassword") = "senderPassword"
    .Item(MsSchm$ & "smtpserverport") = 465
    .Item(MsSchm$ & "sendusing") = 2
    .Item(MsSchm$ & "connectiontimeout") = 100
    .Update
    End With

    Set CdoMsg = CreateObject("CDO.Message")

    With CdoMsg
    Set .Configuration = Cd0Conf
    .From = "senderName"
    .To = "[email protected]"
    .Subject = "This Test"
    .TextBody = "Testing"
    .Send
    End With

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: CDO.Message not working in Win7.64bit

    there are different fields in the configuration for xp to w7
    in xp there is a field senderemailaddress, that is likely to hold a default value from outlook or outlook express, i do not find this field in w7 configuration fields

    you must specify an email address in either the from or sender properties of the email
    no matter what email address you put, the recipient will see [email protected]

    Subject: This Test
    From: "senderName" <[email protected]>
    Date: Wed, June 15, 2011 6:44 pm
    To: xxxxxxxxxxxxxxxx
    Priority: Normal
    Options: View Full Header | View Printable Version

    Testing
    sent from w 7 using your code, with slight modification
    my gmail acct and password
    my address in .to
    my as above (not gmail) address as .sender
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: CDO.Message not working in Win7.64bit

    Quote Originally Posted by westconn1 View Post
    there are different fields in the configuration for xp to w7
    I'm pretty sure this isn't true.

    Quote Originally Posted by westconn1 View Post
    in xp there is a field senderemailaddress, that is likely to hold a default value from outlook or outlook express, i do not find this field in w7 configuration fields
    I think you mean cdoSendEmailAddress, which is the named predefined constant for this field. It is almost always better to use he predefined constants instead of magic strings and numbers.

    Yes, this field is legal in Win2K, XP, Vista, Windows 7, and contemporary Server versions of Windows. However it applies to the SMTP Envelope of an inbound message received using the IIS SMTP Service which does not apply here, and not the Configuration.


    This is probably a lot closer to a working example, done properly instead of using hacked up Field name strings and magic number values:
    Code:
    Option Explicit
    '
    'For Windows 2000 or later. Requires a reference to:
    '
    '   Microsoft CDO For Windows Library
    '
    
    Private Sub SendMsg()
        Dim cdoMsg As New CDO.Message
    
        With cdoMsg
            With .Configuration.Fields
                .Item(cdoSendUsingMethod).Value = cdoSendUsingPort
                .Item(cdoSMTPServerPort).Value = 465
                .Item(cdoSMTPServer).Value = "smtp.gmail.com"
                .Item(cdoSendUserName).Value = "senderName"
                .Item(cdoSendPassword).Value = "senderPassword"
                .Item(cdoSMTPAuthenticate).Value = cdoBasic
                .Update
            End With
            .From = "[email protected]"
            .To = "[email protected]"
            .Subject = "This Test"
            .TextBody = "Testing"
            
            On Error Resume Next
            .Send
        End With
        
        If Err.Number <> 0 Then
            MsgBox "CDO error " & Hex$(Err.Number) & vbNewLine & Err.Description, _
                   vbOKOnly Or vbExclamation
        Else
            MsgBox "Mail sent!", vbOKOnly
        End If
    End Sub
    
    Private Sub Command1_Click()
        SendMsg
    End Sub

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: CDO.Message not working in Win7.64bit

    I'm pretty sure this isn't true.
    i went through the fields list on each and compared
    to produce a list i would have to do on separate computers
    here is the list from xp
    on the w7 i found no field for sendemailaddress,

    from w7
    the difference is, which fields are set by default in the different os, other fields appear in the list when set

    as most times i use cdo, it is from vbs i tend not to use the constants

    error message "From or Sender Field missing"
    i thought this error message was amazingly clear and unambiguous, most unusual
    Last edited by westconn1; Jun 15th, 2011 at 04:34 PM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: CDO.Message not working in Win7.64bit

    In your previous post you said senderemailaddress which is an entirely different thing.

    The difference in Configuration fileds you are seeing is not because of Windows 7, but because you have no email client installed on your Windows 7 computer that CDO recognizes as a Configuration source. In XP you almost certainly have at least Outlook Express present.

    error message "From or Sender Field missing"
    Yes, this tells you exactly where the problem is: wrong syntax value supplied for:

    .Item(cdoSendUserName).Value, or
    .From

    ... or in this case both. See my previous post.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Location
    Far East
    Posts
    232

    Re: CDO.Message not working in Win7.64bit

    Many Thanks gurus; need some testing to fully understand what transpired between the 2 of you. Dilettante: will try not use "hacked up Field name strings and magic number values" for better coding as tutored. Cheers!


    PS Dilettante:
    After playing with your codes which i think smarter, it however gave an CDO error 80040213 in XpWin. The codes i listed above however works fine. Can you have another look at yr codes if there is something missing.
    Last edited by FuzMic; Jun 15th, 2011 at 11:57 PM.

  9. #9
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: CDO.Message not working in Win7.64bit

    Yes, that's probably true enough. I think you need this line:
    Code:
                .Item(cdoSMTPUseSSL).Value = True
    That got left out of my sample, which came from a working test program that does not send to GMail so it didn't need that set to True.

    Your error's description goes like:
    The transport failed to connect to the server
    ... and from there the problem should have been easy enough to diagnose.

  10. #10
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: CDO.Message not working in Win7.64bit

    Quote Originally Posted by westconn1 View Post
    as most times i use cdo, it is from vbs i tend not to use the constants
    That might sound good, except that if by "VBS" you really mean WSH scripts or ASP pages the constants can be available there as well, and you can even predeclare the COM objects involved. You merely need to set a reference using the techniques each script host supports.

    You can even create multiline text resources easily!

    For WSH that means using .WSF files instead of the obsolete .VBS file format that went out of style in 1999.

    Example CDO.wsf:
    Code:
    <job>
      <reference object="CDO.Configuration" />
      <object id="Msg" progID="CDO.Message" />
      <object id="Config" progID="CDO.Configuration" />
      <resource id="MsgSubject">CDO Test</resource>
      <resource id="MsgBody">Greetings Earthling!
    
    This is a test message sent via CDOSYS to ensure that it can still
    be done from recent versions of Windows.
    
    This is only a test.</resource>
      <script language="VBScript">
        Option Explicit
    
        Const SMTPServer      = "MAIL.YOURDOMAIN.COM"
        Const SMTPProxyByPass = "<local>" 'Don't use proxy server.
        Const SMTPAccount     = "YOURACCOUNT"
        Const SMTPPassword    = "YOURPASSWORD"
        Const SMTPSource      = """FRIENDLY NAME"" <[email protected]>"
        Const SMTPDestination = """SOME GUY"" <[email protected]>"
    
        With Config.Fields
          .Item(cdoSendUsingMethod).Value       = cdoSendUsingPort
          .Item(cdoSMTPServer).Value            = SMTPServer
          .Item(cdoSMTPConnectionTimeout).Value = 10 'Quick timeout
          .Item(cdoURLGetLatestVersion).Value   = True 'Ignore cached URL resources.
          .Item(cdoURLProxyBypass).Value        = SMTPProxyByPass
    
          .Item(cdoSMTPAuthenticate).Value      = cdoBasic
          .Item(cdoSendUserName).Value          = SMTPAccount
          .Item(cdoSendPassword).Value          = SMTPPassword
    
          .Update
        End With
    
        With Msg
          Set .Configuration = Config
          .From              = SMTPSource
          .To                = SMTPDestination
          .Subject           = getResource("MsgSubject")
          .TextBody          = getResource("MsgBody")
            
          On Error Resume Next
          .Send
        End With
    
        If Err.Number <> 0 Then
          WScript.Echo "CDO Send error: " & Hex(Err.Number) & vbNewLine _
                     & Err.Description
        Else
          WScript.Echo "Email sent."
        End If
      </script>
    </job>

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Location
    Far East
    Posts
    232

    Re: CDO.Message not working in Win7.64bit

    Thanks Dilettante:
    You are right, i had earlier tested with .Item(cdoSMTPUseSSL).Value = True which was left out in yr sample & then it worked.

    Meanwhile i may have to say sorry for misleading both of you West/Dilettante that cdo don't work in win7.64bit as i just found out the my firewall was actually blocking the access to the server coming from a VB6 .exe.

    I will confirm this later and if so i will mark this thread as resolved.

    PS Latest: Beside the block by the firewall, the other important thing is to use in .to the full address & not just the name ie use .to = "[email protected]"
    Last edited by FuzMic; Jun 17th, 2011 at 01:36 AM.

  12. #12
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: [RESOLVED] CDO.Message not working in Win7.64bit

    Whew!

    The main thing you have it resolved and can move forward.

  13. #13
    New Member
    Join Date
    Jan 2012
    Posts
    8

    Question Re: [RESOLVED] CDO.Message not working in Win7.64bit

    Error message: %1 is not a valid Win32 application

    See topic: CDO.Message not working in 64bit
    Last edited by Hendelcwb; Feb 5th, 2013 at 01:21 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width