G
Guest
I'm receiving the above error message when I instantiate Outlook in my VBA
code (I've pasted the code below). I'm using Access 2003 on Windows XP. The
code was working fine when I was running it on Window 2000 Professional
(still on Access 2003), but when I was upgraded to Windows XP recently, the
runtime error started occurring. Does anyone have any idea how I can fix
this.
Function SendEmail(ByRef olTo As String, ByRef olCc As String, ByRef olBcc
As String, ByRef olSubj As String, ByRef acqid As String, ByRef Internal As
Boolean)
On Error GoTo email_error
Dim msg As String
Dim path As String
Dim path2 As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
'***THE CODE FAIL ON THE NEXT LINE***
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
DoCmd.SetWarnings False
With MailOutLook
.BodyFormat = olFormatRichText
.To = olTo
.CC = olCc
.Bcc = olBcc
.Subject = olSubj
Call getBodyMsg(msg, path, Internal, acqid)
If acqid = "F" Then Exit Function
.Body = msg
.attachments.Add (path & acqid & ".xls")
path2 = Left(path, Len(path) - 19) & "Database Files\"
.attachments.Add (path2 & "Cover Sheet.xls")
.display
End With
DoCmd.SetWarnings True
Exit Function
email_error:
MsgBox "An error has occured. Please take a screen shot of this
error" & vbCrLf & _
"and forward it to the system administrator." & vbCrLf & vbCrLf
& _
"Error Number " & Err.Number & ": " & Err.Description,
vbCritical, "ERROR"
Resume Error_out
Error_out:
End Function
code (I've pasted the code below). I'm using Access 2003 on Windows XP. The
code was working fine when I was running it on Window 2000 Professional
(still on Access 2003), but when I was upgraded to Windows XP recently, the
runtime error started occurring. Does anyone have any idea how I can fix
this.
Function SendEmail(ByRef olTo As String, ByRef olCc As String, ByRef olBcc
As String, ByRef olSubj As String, ByRef acqid As String, ByRef Internal As
Boolean)
On Error GoTo email_error
Dim msg As String
Dim path As String
Dim path2 As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
'***THE CODE FAIL ON THE NEXT LINE***
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
DoCmd.SetWarnings False
With MailOutLook
.BodyFormat = olFormatRichText
.To = olTo
.CC = olCc
.Bcc = olBcc
.Subject = olSubj
Call getBodyMsg(msg, path, Internal, acqid)
If acqid = "F" Then Exit Function
.Body = msg
.attachments.Add (path & acqid & ".xls")
path2 = Left(path, Len(path) - 19) & "Database Files\"
.attachments.Add (path2 & "Cover Sheet.xls")
.display
End With
DoCmd.SetWarnings True
Exit Function
email_error:
MsgBox "An error has occured. Please take a screen shot of this
error" & vbCrLf & _
"and forward it to the system administrator." & vbCrLf & vbCrLf
& _
"Error Number " & Err.Number & ": " & Err.Description,
vbCritical, "ERROR"
Resume Error_out
Error_out:
End Function