Send Emails using CDO in Runtime Enviroment

AceBK

Registered User.
Local time
Today, 07:29
Joined
Dec 2, 2011
Messages
75
Hello,

I am trying to send an email using the CDO method, so when I activate the vba code in my full access program, it works totally fine, but when I go into my runtime environment, on a different machine, it crashes. Am I missing something? Can runtime not run CDO? I am using Access and Runtime 2010.

Code:
Private Sub EmailTest443_Click()
     Set iCfg = CreateObject("CDO.Configuration")
    Set iMsg = CreateObject("CDO.Message")
     With iCfg.Fields
        .Item("[URL]http://schemas.microsoft.com/cdo/configuration/sendusing[/URL]") = 2
        .Item("[URL]http://schemas.microsoft.com/cdo/configuration/smtpserverport[/URL]") = 25
        .Item("[URL]http://schemas.microsoft.com/cdo/configuration/smtpserver[/URL]") = "mail.server.com"
        .Item("[URL]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate[/URL]") = 1
        .Item("[URL]http://schemas.microsoft.com/cdo/configuration/sendusername[/URL]") = "username"
        .Item("[URL]http://schemas.microsoft.com/cdo/configuration/sendpassword[/URL]") = "Password"
        .Item("[URL]http://schemas.microsoft.com/cdo/configuration/sendemailaddress[/URL]") = [EMAIL="someone@someone.com"]someone@someone[EMAIL="pdeboer@premierprinting.ca"].c[/EMAIL]om[/EMAIL]
        .Update
    End With
     With iMsg
         .Configuration = iCfg
        .Subject = "Email Test"
        .to = [EMAIL="someone@someone.com"]someone@someone.com[/EMAIL]
        .TextBody = "Testing the email over the server"
        .send
    End With
     Set iMsg = Nothing
    Set iCfg = Nothing
 End Sub
I have also attached sceenshots of the two errors I got when trying to run this code in the RT environment. Any insight into this is greatly appreciated.

Thanks,
AceBK
 

Attachments

  • Error1.PNG
    Error1.PNG
    4.2 KB · Views: 126
  • Error2.PNG
    Error2.PNG
    6 KB · Views: 166
I don't use CDO but I thought it required a library / dll installed to function? I think it's installed by default if Outlook is installed but not by Access / Runtime.
 
cdosys.dll needs to be installed on any machine that tries to create a cdo.message object.
 
What MarkK said... - beat me to this answer by about 20 minutes.
 
OK, thanks so much for the response, sorry for not responding sooner, my IT department was only able to confirm the status of the CDOSYS files until recently. So we confirmed that this was all working, as well as running some test vba code, but when I run it in the Access Runtime environment, it crashes, any thoughts?
 
The problem is then that somehow you need to force the system to establish the reference at run-time when it first launches , like in the Form_Load routine for the opening form or splash form or whatever you are using.

Look up this stuff in MSDN to get the exact idea, but what I do is I look at the list based on

Access.Application.References (which is a collection)

In essence, you check Access.Applications.References(n).Name - which is the file specification of the given reference. If you cannot find the reference you want, you can do this:

Access.Application.References.AddfromFile file-specification-string

It requires you to establish a list of references you need in a "full" Access environment and somehow get that list into the RunTime environment.
 
when I run it in the Access Runtime environment, it crashes, any thoughts?
Any unhandled error in a runtime file will cause a crash. Implement proper error handling and report back on what error is occurring. Without knowing that, everything is guesswork.
 

Users who are viewing this thread

Back
Top Bottom