I am attempting to email an image from a form. The code I am using is as follows. I am getting an error which makes no sense to me at all. Sure could use some help.
Thanks in advance
Private Sub BtnEmail_Click()
'Check for an email address
If IsNull([EmailAddress]) Then
MsgBox "Enter Email Address"
Me.EmailAddress.SetFocus
Else:
GoTo Continue
End If
Exit Sub
'Send email
Continue:
Dim FileName As String
Dim FilePath As String
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem
FileName = Me.DocumentTitle
FilePath = Me.ImagePath
If oOutlook Is Nothing Then
Set oOutlook = New Outlook.Application
End If
Set oEmailItem = oOutlook.CreateItem(olMailItem)
With oEmailItem
.To = Me.EmailAddress
.Subject = "Document from Greene Memorial Archive System"
.Attachments.Add FilePath
.Send
End With
Set oEmail = Nothing
Set oOutlook = Nothing
MsgBox "Email has been sent to " & Me.EmailAddress
DoCmd.Close acForm, "frmSearch"
DoCmd.Close
DoCmd.OpenForm "frmMenu"
End Sub
The error message is: User defined Type not defined
and it highlights the Dim oOutlook as Outlook.Application statement
I have used this code before without this error
Any ideas?