I have a button with an event procedure that updates a number of fields on my form and it works fine until I try to add the code to send an email.
I found the code here and modified it for my field names. I don't get any errors, it just doesn't send the email. I am using Office 365 and Windows 10.
I would also love the ability to review the email before it is sent, but haven't found anything on how to do that. Any assistance would be greatly appreciated! :)
Dim oApp As New Outlook.Application
Dim oEmail As Outlook.MailItem
Set oEmail = oApp.CreateItem(olMailItem)
oEmail.To = Me.EmailRule
oEmail.Subject = Me.Subject.Value
oEmail.Body = Me.txtBody.Value
If Len(Me.Attachment) > 0 Then
oEmail.Attachments.Add Me.Attachment.Value
End If
With oEmail
If Not IsNull(.To) And Not IsNull(.Subject) And Not IsNull(.Body) Then
MsgBox "Email Sent!"
Else
MsgBox "please fill out the required fields."
End If
End With