This is the first blog of a series describing how to enhance Outlook’s efficiency based on macro usage. Please note that it is not intended to be a coding tutorial, but rather a way to inspire you to develop your own macro to help you be more productive.
image1
Since I don’t know your macro and Outlook knowledge level, I’ll try to keep this as straightforward and simple as possible.

For those who have no clue what a macro is, here is a quick definition:A macro allows you to automate a task that you do repeatedly by creating a shortcut for it.

Check out this link for a handy step-by-step on how to create a macro.

Invite attendees to a meeting

The following is an example of a simplified version of an appointment macro. This version allows me to invite co-workers such as my boss or my team members to join me in a meeting. I may do so through the To-Do-Bar under the section Invite Attendee.

The macro environment

• Open Outlook 2007
• Go to the Visual Basic Editor (Atl+ F11)
• In the Editor’s section, expand the Microsoft Office Outlook Objects folder
• Double-click on ThisOutlookSession
• Something like the following should come up:

image2

The page displayed should be empty. All you need to do is copy and paste the following code:

  ''' This is called when right clicking on any item in Outlook
Private Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Selection As Selection)
    If Selection.Count = 1 Then
        If Selection.Item(1).Class = olAppointment Then
            Set mainCategory = CommandBar.Controls.Add(Type:=msoControlPopup)
            mainCategory.Caption = "Invite Attendee"

            Set firstButton = mainCategory.Controls.Add(Type:=msoControlButton)
            With firstButton
            .Style = msoButtonAutomatic
            .FaceId = 1000
            .Caption = "My Boss"
            .OnAction = "Project1.ThisOutlookSession.InviteToMeeting"
            .Parameter = Selection.Item(1).EntryID
            .Tag = " attendeeEmailAddress "
            End With

            Set secondButton = mainCategory.Controls.Add(Type:=msoControlButton)
            With secondButton
            .Style = msoButtonAutomatic
            .FaceId = 354
            .Caption = "My Team"
            .OnAction = "Project1.ThisOutlookSession.InviteToMeeting"
            .Parameter = Selection.Item(1).EntryID
            .Tag = " attendeeEmailAddress "
            End With
        End If
    End If
End Sub

''' This section modifies the appointment after you click on the preferred menu
Public Sub InviteToMeeting()
    Dim appointmentID As String
    Dim invitationEmail As String
    Dim myAppointmentItem As AppointmentItem

    appointmentID = Application.ActiveExplorer.CommandBars.ActionControl.Parameter
    invitationEmail = Application.ActiveExplorer.CommandBars.ActionControl.Tag

    Set objNamespace = Application.GetNamespace("MAPI")
    Set myAppointmentItem = objNamespace.GetItemFromID(appointmentID)

    myAppointmentItem.Recipients.Add (invitationEmail)
    myAppointmentItem.MeetingStatus = olMeeting
    myAppointmentItem.Save
    myAppointmentItem.Send
End Sub
 

The first section of the code, “Application_ItemContextMenuDisplay”, is called when right clicking on any item. It will add a new item called Invite Attendee to the menu when you select an appointment. As you can see, I’ve customized the menu to display My Boss and My Team.

By following this pattern, you may customize your own menu as you wish.

Here is a quick list of what you might want to modify:
• Tag: if using SherWeb’s Hosted Exchange, the email address or name of recipient
• FaceId: the icon displayed
• Caption: what will appear in the contextual menu

Check out the following website for a list of available icons.

The second section of the code, “InviteToMeeting”, modifies the appointment after you click on the preferred menu. It adds recipients, converts appointments to a meeting, saves any modifications made, and sends out invitations. Furthermore, you can even change the location of the meeting or its time period.

Now test it!

Before testing it, change the email address to a real one. After you’ve changed the email address, create a new appointment and save it. Then, go to your To-do Bar or in your Calendar, right click on the appointment and select the appropriate attendee. The invitation email was sent and you should receive an answer soon. If it doesn’t work, I suggest you try restarting Outlook. You will be prompted to enable macro usage.

More macro?

For more information about customizing the contextual menu, please access the following for Microsoft’s Context help menu.

If there’s a script you would like to have for Outlook, you can post a comment describing the functionality that you need and we will try to create one based on your request. Also, let us know if this example was too easy or too hard for you to understand.

* This code is presented as-is. You should take the time to review it and see if it will meet your requirements before using it. SherWeb and the author of this macro are not responsible for any possible issues caused to your computer or network.

by Philippe Paultre. A software developer at SherWeb, Philippe works mainly on our Account Manager and in R&D. He has been with the company since November 2008.

Google Reader or Homepage
Add to My Yahoo!

Comment this article

Blog Roll

Chicklets

Google Reader or Homepage
Add to My Yahoo!