I would like to send an email with an attachment upon clicking a button on a form. Here is the code I have:
'open Outlook, attach zip folder or file, send e-mail
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.BodyFormat = olFormatRichText
.To = txtUserID
''.cc = ""
''.bcc = ""
.Subject = "text here"
.HTMLBody = "text here"
.Attachments.Add ("file path")
''.DeleteAfterSubmit = True 'This would let Outlook send the note without storing it in your sent bin
.send
End With
However, when I attempt to execute this code, I get "Compile error: User-defined type not defined" with the 'appOutLook As Outlook.Application' highlighted.
What am I missing? Please help. Thank you!