Hi all
I am very close in getting this to work. I need your help to get it over the line.
An email is created and is opened for edditing to the user. I want to be able to tell access if the user then sends the email or discards it. Having researched this I found the below snippets of code which look great. Unfortunately it is not quite working. The emial is created correctly but upon either sending/discarding nothing happens. I dont get a msgbox (which I am expecting). Any help is much appreciated.
Here is the class module called "itmevt"
Code:
Option Compare Database
Option Explicit
Public WithEvents itm As Outlook.MailItem
Private Sub itm_Send(Cancel As Boolean)
Dim blnSent As Boolean
On Error Resume Next
blnSent = itm.Sent
If Err.Number = 0 Then
MsgBox ("NO!")
Else
MsgBox ("YES!")
End If
End Sub
Here is the procedure that calls the
Code:
Option Compare Database
Private Sub Command0_Click()
Dim outlookObj As Outlook.Application
Dim itmevt As New itmevt
Set outlookObj = New Outlook.Application
Set itmevt.itm = Outlook.Application.CreateItem(0)
With itmevt.itm
.BodyFormat = olFormatHTML
.To = "craig.o'neill@boi.com"
.CC = "craig.o'neill@boi.com"
.Subject = "Test email subject line"
.Display
End With
End Sub