Taming Outlook

Chris Kunicki’s recent blog entry (http://blogs.officezealot.com/MT/mt-tb.cgi/159) on taming Outlook reminded me of a little modification I made to Outlook to get a specific behavior I liked.

Outlook 2003 has the cool feature for flagging items for follow up. That’s funky, but before I had 2003 I wanted a similar kind of thing:  a way to take a mail message and quickly turn it into a task in a way I wanted. Even though I now use the flagging feature, I still use my little sub for some items. Essentially, this procedure takes the selected mail message, creates a new task, extracts the mail contents and puts them in the task notes.

I added a button to the toolbar that maps to my sub. 

Public Sub AddToTasks()

  Dim olTask As Outlook.TaskItem

  Dim olMail As MailItem

  Dim olIns As Inspector

  Dim olExp As Explorer

  Set olTask = Application.CreateItem(olTaskItem)

  Set olExp = Application.ActiveExplorer

  If olExp.CurrentView <> "Messages" Then Exit Sub

  If olExp.Selection.Count <> 1 Then Exit Sub

  Set olMail = olExp.Selection.Item(1)

  With olTask

    .Subject = olMail.Subject

    .Body = olMail.Body

    .StartDate = Now

    .DueDate = DateAdd("d", 7 - Format$(Date, "w", vbSaturday), Date)

    .ReminderSet = False

  olTask.Status = olTaskInProgress

  End With

  Set olIns = olTask.GetInspector

  olIns.Display ("True")

End Sub

This needs to go in the ThisOutlookSession. I added no error handling, and I made some assumptions about my current view and so on. I can do that when it is just for my machine!


What strikes me is how easily these kinds of things can be done. We really begin to take it for granted that we can customize Office in such an awfully easy way. It’s when we get down to the secret MAPI properties that things get ethereal.


Check out the Office Developer Center at http://msdn.microsoft.com/office


Rock on

Comments (6)
  1. KC Lemson says:

    Great idea for a use for VBA, John. Totally agree on the ease of use of VBA in general, it makes my life in office so much easier.

    I think I’m going to take this snippet and change it to meet my needs a little more, but I really like the user scenario (currently I do Edit | Copy to Tasks on about 5% of the mail I receive). One thing I’d like to add is a link to the item in the sent items folder, so I can reply to the last one from me on the thread… I’m pretty sure that’s possible, but either way it’ll be fun to figure out. Thanks for giving me a project! 🙂

  2. KC Lemson says:

    Well I never did figure out the link to sent items, but at least I got the 80% case working =) Thanks for the inspiration.

Comments are closed.

Skip to main content