|
-
Jun 15th, 2011, 10:26 AM
#1
Re: CDO.Message not working in Win7.64bit
 Originally Posted by westconn1
there are different fields in the configuration for xp to w7
I'm pretty sure this isn't true.
 Originally Posted by westconn1
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|