Hmm I was trying something along those lines I believe, from the MSDN
site on the ItemSend event where it shows some code to use, I grabbed
that and warped it into my existing code but now whenever I hit send I
get an error of "Object required" and the debugger highlights the
line: Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As
Boolean)
Here's the code:
Public WithEvents myOlItems As Outlook.Items
Public WithEvents myOlApp As Outlook.Application
Public Sub Application_Startup()
Set myOlItems = Session.GetDefaultFolder(olFolderInbox).Items
Set myOlApp = CreateObject("Outlook.Application")
MsgBox ("In startup")
End Sub
Private Sub myOlItems_ItemAdd(ByVal Item As Object)
~~~~ blah blah ~~~~
End Sub
Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
Set myCount = 1
For Each objRecip In Item.Recipients
MsgBox (objRecip.Address)
If InStr(1, objRecip.Address, "***@gmail.com") Then
MsgBox ("bingo")
Item.Recipients.Remove myCount
End If
myCount = myCount + 1
Next
prompt = "Are you sure you want to send " & Item.Subject & "?"
If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
Cancel = True
End If
End Sub