Home > Uncategorized > Outlook macros: what.

Outlook macros: what.

I had a request to make Outlook do something after an email is sent.

Here’s how you do that (I’m not too exciting this morning):

'https://social.msdn.microsoft.com/Forums/en-US/d5248a16-8100-4cbf-a720-b877c57b90ed/capturing-meeting-send-event-in-outlook-addin-using-vbnet?forum=outlookdev
'https://msdn.microsoft.com/en-us/library/office/ff865076(v=office.14).aspx
'http://stackoverflow.com/questions/11263483/how-do-i-trigger-a-macro-to-run-after-a-new-mail-is-received-in-outlook
'http://stackoverflow.com/questions/1565231/is-it-possible-to-run-a-vba-function-whenever-outlook-starts-up
Public WithEvents myOlApp As Outlook.Application
Private Sub Application_Startup()
    Call Initialize_handler
End Sub
Public Sub Initialize_handler()
 Set myOlApp = Outlook.Application
 MsgBox ("I be loading")
End Sub
Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
 Dim prompt As String
 prompt = "Are you sure you want to send " & Item.Subject & "?"
 If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
 Cancel = True
 End If
End Sub

Pop up the developers tab on your ribbon, and insert that code into the “ThisOutlookSession.” Save. Close and reopen. Macro security is important.

If we move this into production, I’ll work on signing the macro also.
 

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: