Wednesday, June 17, 2009

Pimp your Outlook messaging

Pimp your Outlook messaging

Outlook is so common rich application.. but it lacks of some simple and so much needed functions like:
  • Edit message as new
  • New message with already filled CC
  • Reply to message with already filled CC

But real cool hackers never give up even if your best friend name is Bill.

Let's do it.



Pre-requests
  1. MS Outlook 2003/2007
  2. Patience (you've mentioned 'MS' in the point one, ain't so?)
All said below is tested on the MS Outlook 2003 and MS Outlook 2007, screenshots were done with the Outlook 2007.


Outlook and VBA macros
We start with the "Edit message as new" feature. "Edit as new" is a must-have when you want simply re-send message to somebody (not to forward, or to reply) or when you need to make some changes to message you'd sent earlier and re-send again. For sure, there is a standard function in Outlook for this: double click on some message -> click on the "Other Actions" item in toolbar -> choose "Edit message" in drop-down list. But we are lazy enough, we wish to do this with one click! So:
  1. Open Outlook
  2. Tools -> Macro -> Visual Basic Editor (or simply press ALT+F11)
  3. In the opened editor you'll see project structure on the left. Expand it: Project1 -> Microsoft Office Outlook Objects -> double click on node ThisOutlookSession.
  4. Paste the code below to the opened editor

    Sub EditAsNew()
    Dim msg As Outlook.MailItem
    Set msg = Outlook.ActiveExplorer.Selection(1)
    If msg Is Nothing Then Exit Sub
    If Not TypeOf msg Is Outlook.MailItem Then Exit Sub
    
    Dim newMsg As Outlook.MailItem
    Set newMsg = Application.CreateItem(olMailItem)
    newMsg.To = msg.To
    newMsg.CC = msg.CC
    newMsg.BCC = msg.BCC
    newMsg.Subject = msg.Subject
    Call copyAttachments(msg, newMsg)
    newMsg.Body = msg.Body
    newMsg.Display
    
    Set msg = Nothing
    Set newMsg = Nothing
    End Sub
    
    Sub copyAttachments(objSourceItem, objTargetItem)
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
    strPath = fldTemp.Path & "\"
    For Each objAtt In objSourceItem.Attachments
    strFile = strPath & objAtt.FileName
    objAtt.SaveAsFile strFile
    objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
    fso.DeleteFile strFile
    Next
    
    Set fldTemp = Nothing
    Set fso = Nothing
    End Sub
    

  5. Save (CTRL+S) and close Visual Baic Editor
  6. Lets check! Select some message from 'Sent' folder and press ALT+F8
  7. You'll probably see Outlook message "Microsoft Office has identified a potential security concern"
  8. Outlook warning message on macros launch No fear! You can click "Enable Macros" and next time you'll call macros you won't get warning message. Until you restart Outlook. If you don't want to be bothered with this message you may turn off macros protection in Outlook (here regular security remark goes). To do it: Tools -> Macro -> Security -> Macro Security -> No Security checks for macros
  9. In opened window with list of available macroses choose our 'EditAsNew' and run it (button "Run")
  10. You should see chosen message ready to be edited and re-send

Well, it works (at least - on my side). But life is too shot to accomplish items 5 and 7 each time you want to re-send message. That's why you'll read next chapter - Outlook tuning.



Outlook tuning
I know 3 methods to make world go around: keyboard, mouse and "Mu-u-u-m! Please, ...". It is possible to use shortcuts to launch macroses and I'm going to show how to do this in the next post.
But now, mouse-users, unite! We are going to customize Outlook toolbar- remove rarely used items and add our hand-made beauties.
  1. Right-click on standard toolbar
    Customize default Outlook toolbar
    and choose "Customize"
  2. Click on any unwanted item from the standard toolbar and drag it somewhere out if toolbar - you'll see dagger - drop the item and it will disappear from the toolbar
  3. You've finished him/them? Let's add new button to launch "EditAsNew" macros. Recall (if needed) menu "Customize" (see step 1) -> tab Commands -> Categories: Macros -> Select macros "EditAsNew"
    Outlook. Customize macros for toolbar
  4. Drag macros "EditAsNew" to the the toolbar and place it where you like. You'll get something like this:
    Outlook. Button on the toolbar to launch macros
  5. Do you like this informative caption for our new button? Me- not. But this is Outlook and everything is possible tonight. Let's rename caption: menu "Customize" (step 1 again) -> tab Commands -> Rearrange commands -> Choose a menu or toolbar to rearrange: Toolbar Standard -> select naughty "Project1.ThisOutlookSession.EditAsNew"
    Outlook. Customize buttons on the standard toolbar
  6. Click to Modify Selection and change field "Name" in drop-down menu to whatever you like. As for me - straight "EditAsNew" is well enough.
That's all! The road wasn't easy and paved with yellow bricks but.. we just made MS Outlook more user-oriented - quite a lot for a mere mortals!



The rest
As you might remember, at the beginning we were talking also about such features as
  • New message with already filled CC
  • Reply to message with already filled CC
  • Reply to all with already filled CC
A bit of explanations: imagine you are THE BIG BOSS. For sure you have pretty nice secretary and one of her duties (one of, I said) is to be up on everything about your day plan. Each time you send (or reply to) e-mail concerning to your business meets- you have to put Her (that secretary, aha) in CC. You are still doing so? We are coming to you then!
To add these features you need:
  • VBA code for macroses (see below). Don't forget to modify the code - change e-mail from "prettysec@myrichoffice.com" to the correct one
  • Run through the steps described above in a chapters "Outlook and VBA macros" and "Outlook tuning". NOTE: macroses should be pasted to the VBA editor, one after one.
MS Outlook and "New message with already filled CC"
Sub NewWithCc()
Dim msg As Outlook.MailItem
Set msg = Application.CreateItem(olMailItem)
msg.CC = "prettysec@myrichoffice.com"
msg.Display

Set msg = Nothing
End Sub

MS Outlook and "Reply to message with already filled CC" feature
Sub ReplyWithCc()
Dim msg As Outlook.MailItem
Set msg = Outlook.ActiveExplorer.Selection(1)
If msg Is Nothing Then Exit Sub
If Not TypeOf msg Is Outlook.MailItem Then Exit Sub

Dim reply As Outlook.MailItem
Set reply = msg.reply
reply.Display
reply.CC = "prettysec@myrichoffice.com"

Set msg = Nothing
Set reply = Nothing
End Sub

MS Outlook and "Reply to all with already filled CC" feature
Sub ReplyToAllWithCc()
Dim msg As Outlook.MailItem
Set msg = Outlook.ActiveExplorer.Selection(1)
If msg Is Nothing Then Exit Sub
If Not TypeOf msg Is Outlook.MailItem Then Exit Sub

Dim reply As Outlook.MailItem
Set reply = msg.ReplyAll
reply.Display
reply.CC = msg.CC + "; prettysec@myrichoffice.com"

Set msg = Nothing
Set reply = Nothing
End Sub



The last
My real Outlook standard toolbar screenshot. Check it out!
Customized standard MS Outlook toolbar



4 comments:

  1. In EditAsNew, you copy the BCC from the original message to the new message, but you wouldn't actually have access to the BCC line. Otherwise, great post. You might also want to check the current selection to make sure something (a mailitem) is selected.

    ReplyDelete
  2. I've just checked issue with BCC- 'editAsNew' work correctly (at least on my Outlook 2007).
    Concerning checking.. You are absolutely right- do check or love rake.
    I've reformed!

    ReplyDelete
  3. Some days ago I was at the Inet and caught sight there - how do you fix a corrupt pst/ost. It interested me good design. I was shocked because of I had had a lot of corrupted emails on my PC. And the program recovered theirs for seconds and first of all I didn't pay the money.

    ReplyDelete
  4. Wow!
    Have you wrote a function "redirect", to be used instead of "forward"? (I've seen it in Eudora, and now I'm using it with an add on in Thuderbird)

    It's very usefull when I receive a message, that is not for me and I would like to send it to the actual receiver, without formatting and leaving the same sender! It's ideal for info@xxxx.com messages, to be sent to the right person.

    ReplyDelete