I have an Access FE and an SQL Express BE.
I tried using the following code which works fine in an Access13 FE and ACE BE.
I call the SendEmail fumction using
The SendEmail function
I receive the following error, on execution of the following line
I tried using the following code which works fine in an Access13 FE and ACE BE.
I call the SendEmail fumction using
Code:
Dim varDum As Variant
varDum = SendEmail("MyEmailExample.com", "", "", True, "", Me.strPath)
The SendEmail function
Code:
Function SendEmail(strTo As String, strSubject As String, strBody As String, bEdit As Boolean, _
Optional strBCC As Variant, Optional AttachmentPath As Variant)
'Send Email using late binding to avoid reference issues
Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim objOutlookRecip As Object
Dim objOutlookAttach As Object
Dim i As Integer
Const olMailItem = 0
On Error GoTo ErrorMsgs
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.Subject = strSubject
.Body = strBody
.Importance = 2
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
If IsArray(AttachmentPath) Then
For i = LBound(AttachmentPath) To UBound(AttachmentPath) - 1
If AttachmentPath(i) <> "" And AttachmentPath(i) <> "False" Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath(i))
End If
Next i
Else
If AttachmentPath <> "" Then
'***********************************************************************
Set objOutlookAttach = .Attachments.Add(AttachmentPath) '**************
'***********************************************************************
End If
End If
End If
If bEdit Then
.display
Else
.Send
End If
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
ErrorMsgs:
MsgBox Err.Number & " - " & Err.Description
Exit Function
End Function
I receive the following error, on execution of the following line
Code:
Set objOutlookAttach = .Attachments.Add(AttachmentPath)