Friday 5 November 2010

Let outlook do the thinking: Time based header for outlook

              Myself, being lazy tend to respect the people with greeting appropriate to the time of the day, like Good Morning, Good Afternoon & Good Evening.

   But keeping track of code, time, life and every thing else takes a toll and some times i try to automate these bits as much as possbile to simplify my life.
                  To cut short i desgined a macro which could populate the outlook text for new email with correct headers based on the time of day with the shortcut "Ctrl+J"

To accomplish this

1. Start you outlook..
2. Open a new email interface, press Alt+F11 on you key board to power up your VBA editor.

Navigate to location "Normal" as shown in the image below:



Insert a module named "CustomTextMacro" (any thing you like as it personal choice
In that module Type(if you like)/CopyPaste in the following peice of code:

Sub InsertCustomText_Mail()
Selection.HomeKey Unit:=wdStory
Selection.Font.Color = wdColorDarkBlue
If TimeValue(Time()) <= TimeValue("12:00:00") Then
Selection.TypeText Text:="Good Morning,"
ElseIf TimeValue(Time()) <= TimeValue("16:00:00") Then
Selection.TypeText Text:="Good Afternoon,"
ElseIf TimeValue(Time()) > TimeValue("16:00:00") Then
Selection.TypeText Text:="Good Evening,"
End If

Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:="Thank you"
Selection.TypeParagraph
Selection.TypeText Text:="Regards"
Selection.TypeParagraph
Selection.TypeText Text:="Amol Pandey"
Selection.TypeParagraph
Selection.TypeParagraph
End Sub

3. Then once completed, navigate to following location as shown in the image:



clicking on it will bring the following window:




then navigate to the Keyboard section of the window and click on it to bring on the following next window:




In this window we will find our macro listed and assigning the macro the required shortcut keys will accomplish the job and, there we have out complete automated solution for the custom outlook header.

Just press the magical shortcut, and there you go on your new email you have the custom header based correctly on the times of the day...

Hope it simplifies your lives as mine...

No comments: