尝试从访问2013发送电子邮件到Outlook 2013时发生随机出现的错误(48,错误加载DLL)

问题描述:

我目前正在访问2013数据库。在其中一个表单中,我有一个收集信息的按钮,然后将其放入Outlook 2013电子邮件并发送。代码本身起作用,但有时(我无法预测何时)出现"run-time error '48', Error loading DLL"错误。一旦发生这种情况,我必须重新启动计算机才能使按钮再次工作。我只用VBA工作了几周,并没有找到解决这个问题的方法。尝试从访问2013发送电子邮件到Outlook 2013时发生随机出现的错误(48,错误加载DLL)

- 这个程序(它是一个拆分数据库)的计算机上都有它们的office 2010和2013。我不知道这是否会导致这个问题,但我不知道当他们在PC上同时排除它时会发生什么。

- 这个问题发生在方案的两项.accde和.ACCDB版本

here is what the debugger shows when the error happens

'below is the code for the button that sends the email 
Public Sub Command239_Click() 

Dim oApp As Outlook.Application 
Dim oMail As MailItem 
Dim db As Database 

'there is code a bunch of code between here that does not 
'relate to sending the email 

    'accessing outlook 
Set oApp = CreateObject("Outlook.application") 
Set oMail = oApp.CreateItem(olMailItem)  ' <<<<<<<<<<< this line is highlighted in yellow >>>>>>>>>>>>>>  

'this is for the body of the email. 
'things in quotes are text 
'& between variables text and newlines 
'type the variable to write its value 
'vbCrLF goes to the next line 
oMail.Body = "Incident Log: " & clsORopen & ", " & Lgst & ", " & Tme & vbCrLf & Division & ": " & Location & ", " & secLocation & vbCrLf & "Circuit/Apparatus: " & Circuit & vbCrLf & "Caused by: " & cause & ", " & rtcause & vbCrLf & vbCrLf & Disturbance & vbCrLf & vbCrLf & "Person Notified: " & Notified & vbCrLf & "Returned to Normal: " & Returned & vbCrLf & "User: " & getusername & " Date: " & Format(Now, "MMM,d,yyyy") 

'the subject 
oMail.Subject = Division & " - " & Tyype & ", " & Circuit 

'sending to these people 
oMail.To = emaillist 
oMail.Send 
Set oMail = Nothing 
Set oApp = Nothing