R
Robbo
I have just bought a new computer with Windows 7 and I am having trouble
using the following CDO function to send an e-mail unless I include the
optional SMTP Server details. With XP, provided I configured Outlook Express
(OE), the settings were available to me and I didn't need to define the SMTP
Server. I understand OE writes the values to the following registry key:
"HKEY_CURRENT_USER\Software\Microsoft\Internet Account
Manager\Accounts\00000001". However with Windows 7 I can't use OE and I can't
figure out how to access the SMTP Server values. That means I can't test
software on my machine that is used on all the XP machines that need the
application. Can anyone tell me if there is a way to get these values loaded
and registered properly on a Windows 7 Machine? The funciton I use is as
follows:
Function CDOEmail(sTo As String, _
CC As String, _
BCC As String, _
Subject As String, _
TextBody As String, _
Attachment As String, _
Optional SMTPserver As String) As Boolean
Dim iMsg As Object
Dim iConf As Object
Dim sSender As String
10 On Error GoTo CDOEmail_Error
20 fLog "CDOMail", "CDOEmail sequence commencing: " & sTo & ", " & CC
& ", " & BCC & ", " & Subject _
& ", " & TextBody & ", " & Attachment
30 If Nz(gsStoreIdent, "") = "" Then
40 fLog "CDOEmail", "Initialiser launched because gsStoreIdent
was: " & gsStoreIdent
50 Initialiser
60 End If
70 sSender = DLookup("Email", "tblStores", "Ident = '" & gsStoreIdent
& "'")
80 sSender = Mid(sSender, 1, InStr(sSender, "@") - 1) & " <" &
sSender & ">"
90 Set iMsg = CreateObject("CDO.Message")
100 Set iConf = CreateObject("CDO.Configuration")
110 If Len(SMTPserver) > 0 Then
Dim Flds As Variant
120 iConf.Load -1 ' CDO Source Defaults
130 Set Flds = iConf.Fields
140 With Flds
150
..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
160
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
= SMTPserver
170
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
180 .Update
190 End With
200 End If
210 On Error Resume Next
220 With iMsg
230 Set .Configuration = iConf
240 .To = sTo
250 .CC = CC
260 .BCC = BCC
270 .FROM = sSender
280 .Subject = Subject
290 .TextBody = TextBody
300 If Dir(Attachment) <> "" And Attachment <> "" Then
310 .AddAttachment Attachment
320 End If
330 .Send
340 If Err.Number = -2147220973 Then
350 fLog "CDOEmail", "The transport failed to connect to the
server."
360 CDOEmail = 0
370 ElseIf Err Then
380 Stop
390 fLog "CDOEmail", "Email failed to send " & Err.Number & "
" & Err.Description
400 MsgBox "Error : " & Err.Number & " " & Err.Description & "
Please note the details of this message."
410 CDOEmail = 0
420 Else
430 CDOEmail = -1
440 End If
450 End With
460 On Error GoTo 0
470 fLog "CDOMail", "CDOEmail sequence finished normally"
480 Exit Function
CDOEmail_Error:
490 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure CDOEmail of Module CDOMail"
Exit Function
Resume
End Function
using the following CDO function to send an e-mail unless I include the
optional SMTP Server details. With XP, provided I configured Outlook Express
(OE), the settings were available to me and I didn't need to define the SMTP
Server. I understand OE writes the values to the following registry key:
"HKEY_CURRENT_USER\Software\Microsoft\Internet Account
Manager\Accounts\00000001". However with Windows 7 I can't use OE and I can't
figure out how to access the SMTP Server values. That means I can't test
software on my machine that is used on all the XP machines that need the
application. Can anyone tell me if there is a way to get these values loaded
and registered properly on a Windows 7 Machine? The funciton I use is as
follows:
Function CDOEmail(sTo As String, _
CC As String, _
BCC As String, _
Subject As String, _
TextBody As String, _
Attachment As String, _
Optional SMTPserver As String) As Boolean
Dim iMsg As Object
Dim iConf As Object
Dim sSender As String
10 On Error GoTo CDOEmail_Error
20 fLog "CDOMail", "CDOEmail sequence commencing: " & sTo & ", " & CC
& ", " & BCC & ", " & Subject _
& ", " & TextBody & ", " & Attachment
30 If Nz(gsStoreIdent, "") = "" Then
40 fLog "CDOEmail", "Initialiser launched because gsStoreIdent
was: " & gsStoreIdent
50 Initialiser
60 End If
70 sSender = DLookup("Email", "tblStores", "Ident = '" & gsStoreIdent
& "'")
80 sSender = Mid(sSender, 1, InStr(sSender, "@") - 1) & " <" &
sSender & ">"
90 Set iMsg = CreateObject("CDO.Message")
100 Set iConf = CreateObject("CDO.Configuration")
110 If Len(SMTPserver) > 0 Then
Dim Flds As Variant
120 iConf.Load -1 ' CDO Source Defaults
130 Set Flds = iConf.Fields
140 With Flds
150
..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
160
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
= SMTPserver
170
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
180 .Update
190 End With
200 End If
210 On Error Resume Next
220 With iMsg
230 Set .Configuration = iConf
240 .To = sTo
250 .CC = CC
260 .BCC = BCC
270 .FROM = sSender
280 .Subject = Subject
290 .TextBody = TextBody
300 If Dir(Attachment) <> "" And Attachment <> "" Then
310 .AddAttachment Attachment
320 End If
330 .Send
340 If Err.Number = -2147220973 Then
350 fLog "CDOEmail", "The transport failed to connect to the
server."
360 CDOEmail = 0
370 ElseIf Err Then
380 Stop
390 fLog "CDOEmail", "Email failed to send " & Err.Number & "
" & Err.Description
400 MsgBox "Error : " & Err.Number & " " & Err.Description & "
Please note the details of this message."
410 CDOEmail = 0
420 Else
430 CDOEmail = -1
440 End If
450 End With
460 On Error GoTo 0
470 fLog "CDOMail", "CDOEmail sequence finished normally"
480 Exit Function
CDOEmail_Error:
490 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure CDOEmail of Module CDOMail"
Exit Function
Resume
End Function