Outlook macro example

By | 2018-07-04

To setup macro script for Rule to call.

    1. Press Alt+F11 in Outlook
    2. VBA code screen will be prompted.
    3. Select Project1 -> Microsoft Outlook Objects -> ThisOutlookSession
    4. Create subroutine with Public Sub Routine_name(Item As Outlook.MailItem) as signature
    5. Then you can found this subroutine in Rule window.

This example remove attachment and forward to someone.

Public Sub ForwardToAntony(Item As Outlook.MailItem)

Dim objForwardedItem As MailItem
Set objForwardedItem = Item.Forward

Do Until objForwardedItem.Attachments.Count = 0
objForwardedItem.Attachments.Remove (1)
Loop

objForwardedItem.To = "this_is@email.com"
objForwardedItem.Send

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *