[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1857
  • Last Modified:

CDO Email coming up with "The "SendUsing" configuration value is invalid" error on Windows 7

My old laptop needed replacing and the new one I bought runs on Windows 7 instead of XP. I have an Access Program that uses CDO Email. It works well on XP machines but is coming up with "The "SendUsing" configuration value is invalid." error on my Windows 7 machine. I am not stipulating my SMTP server so it should be using the default settings, which I found out on XP machines, seemed to be the settings loaded in Outlook Express (not Outlook). Outlook Express wont run on Windows 7 Home Premium so I have tried installing and configuring Windows Live Mail but that doesn't seem to have fixed the problem either. This application is being distributed to users with XP and OE so it works fine on their machines but the way it is, I can't test it on mine. Can anyone tell me what I need to do to configure it to work on Windows 7?

Following is the function I am using:

Function CDOEmail(sTo As String, _
                 CC As String, _
                 BCC As String, _
                 Subject As String, _
                 TextBody As String, _
                 Attachment As String, _
                 Optional SMTPserver As String, _
                 Optional DisplayPleaseWait As Boolean) As Boolean
          Dim iMsg As Object
          Dim iConf As Object
          Dim sSender As String
         
10        On Error GoTo CDOEmail_Error

20        If DisplayPleaseWait Then PleaseWait "Sending e-mail"

30        fLog "CDOMail", "CDOEmail sequence commencing: " & sTo & ", " & CC & ", " & BCC & ", " & Subject _
          & ", " & TextBody & ", " & Attachment

40        If Nz(gsStoreIdent, "") = "" Then
50            fLog "CDOEmail", "Initialiser launched because gsStoreIdent was: " & gsStoreIdent
60            Initialiser
70        End If
         
80        sSender = Nz(DLookup("Email", "tblStores", "Ident = '" & gsStoreIdent & "'"), EMAILTO)
90        sSender = Mid(sSender, 1, InStr(sSender, "@") - 1) & " <" & sSender & ">"
         
100       Set iMsg = CreateObject("CDO.Message")
110       Set iConf = CreateObject("CDO.Configuration")

120       If Len(SMTPserver) > 0 Then
              Dim Flds As Variant
130           iConf.Load -1    ' CDO Source Defaults
140           Set Flds = iConf.Fields
150           With Flds
160               .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
170               .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
                                 = SMTPserver
180               .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
190               .Update
200           End With
210       End If

220       On Error Resume Next
230       With iMsg
240           Set .configuration = iConf
250           .To = sTo
260           .CC = CC
270           .BCC = BCC
280           .FROM = sSender
290           .Subject = Subject
300           .TextBody = TextBody
310           If Dir(Attachment) <> "" And Attachment <> "" Then
320               .AddAttachment Attachment
330           End If
340           .Send
         
350           If Err.Number = -2147220973 Then
360               fLog "CDOEmail", "### Error ### The transport failed to connect to the server."
370               CDOEmail = 0
380           ElseIf Err Then
390               Stop
400               fLog "CDOEmail", "### ERROR ### Email failed to send " & Err.Number & " " & Err.Description
410               MsgBox "Error : " & Err.Number & " " & Err.Description & " Please note the details of this message."
420               CDOEmail = 0
430           Else
440               CDOEmail = -1
450           End If
460       End With

470       On Error GoTo 0
480       fLog "CDOMail", "CDOEmail sequence finished normally"
         
490       If DisplayPleaseWait Then PleaseWait , True
         
500       Exit Function

CDOEmail_Error:

510       MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure CDOEmail of Module CDOMail"
520       If DisplayPleaseWait Then PleaseWait , True
Exit Function
Resume
End Function
0
Rob4077
Asked:
Rob4077
  • 4
  • 4
1 Solution
 
puppydogbuddyCommented:
Hi Rob,
I don't know if this helps, but according to the following link, your code line 170 should be as shown below, and not as you have it.  You need to replace "myserver" with your server name.
     http://techrepublic.com.com/5208-11184-0.html?forumID=47&threadID=198627&messageID=2069425&tag=content;leftCol
           
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.myserver.com"
                                                                                                           ^^^^^^^^^^^^^^^^^^^

If there is a problem with your line 170 (I don't know for sure), it may not have shown up in your XP machine because the remote SMTP server already existed on that machine and that line in your code was not critical. Your Win 7 machine probably had not been configured for a remote SMTP server, so it  does not exists and your code line 170 was not syntaxically correct to create it.
0
 
Rob4077Author Commented:
Hi PDB,
I am sure that's the problem but rather than encode the SMTP server in line 170, how can I configure it to work the same way it does on XP? The code I have seems to work on any standalone XP machine without a hitch (as long as the Outlook Express on that machine is configured to send/recieve e-mails via a valid account, even if the user never starts OE), making it easy to transfer. If I have to encode the SMTP server details in line 170 then it is far less portable.
Rob
0
 
Rob4077Author Commented:
BTW, I did a search through the registry on the XP and found where I think all the SMTP server settings have been written. How they got there I don't know and how to get my MS Access to recognise them. Does this help figure out what I need to do???
 "HKEY_CURRENT_USER\Software\Microsoft\Internet Account Manager\Accounts\00000001"
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
puppydogbuddyCommented:
While I personally don't know of any way to "read" the mail server settings from the Registry, that is something I can certainly look into.  

Idea......, there appears to be "standard" settings associated with each different mail server program dependent on the Email client software in use, as shown in this link:  
                     http://www.on-line.com/Email/
so maybe you could use a "select case" and execute the applicable server construct dependent on the Client email software that is used.
0
 
Rob4077Author Commented:
Hi PDB, I wonder if you could help me understand a little about the above code that may help me figure out what is going on. I have a massive knowledge gap. Bear in mind that I borrowed and modified the code. Specifically the questions in bold
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")  '<<<Where do I find out more about the CDO Configuration object?
iConf.Load -1    ' CDO Source Defaults ' <<< What is the significance of this?

'The following code assigns values to these fields, however in my XP system (because the values are loaded by OE into the "CDO Configuration" the values are already there - I don't need to enter any values. In fact "iConf.Fields("http://schemas.microsoft.com/cdo/configuration/sendemailaddress").Value" even contains the email address. What I need is a way to load these values in Windows 7 and make them stick. Otherwise I will need to put code in my function that says something like:
If Nz(Environ("ComputerName"), "xx") = "ROB4077") then ' Set the values
   With Flds
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
                                 = SMTPserver
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        .Update
   End With
 Endif
 
0
 
puppydogbuddyCommented:
This link appears to be an excellent source of info about CDO and the CDO object model:
                               http://www.cdolive.com/cdo1.htm
                                      (use the menu on the left side of your screen)

This link (if I understand it correctly) may be the solution to your problem by providing a single remote server, changing just 2 lines of your code, and configuring CDO through a standard, free gMail (Google Email) server.
                            http://forums.webwizguide.com/topic24104.html
                                  (scroll down to the section that says "THE SOLUTION")
               
0
 
puppydogbuddyCommented:
Rob,
If you want to pursue changing the smtp mail settings in the Windows Registry using vba, this link will show you the how within allowable constraints:
                   http://vba-corner.livejournal.com/3054.html
 
0
 
Rob4077Author Commented:
Sorry for the delay. I have a bad, bad cold that has put me out of commission for a couple of days. The info you provided will help me better understand the CDO Object library and see if I can find a more universal solution. Thanks for your kind assistance
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now