Until last year I didn't have enough time to realize his idea but when I did it people noticed the difference and started coming back to know how the tip of the day or definition of the day appeared at the bottom of each message I sent or replied for the first time. Most of the recipients thought I was jotting the content every time I sent until they were made aware that outlook ships with Visual Basic for Applications (VBA).
1998 the idea was conceived 2003 idea was realized it's 2004 and his ideas are sellable even today!. Read what he has to say on this "Why is technology DISABLED".
Recently couple of my friends asked me to share the code and so here it is.
Steps:
- Open Outlook
- Press Alt+F11 or go to Tools->Macro->Visual Basic Editor
- Paste the following code
- Read the inline comments to understand the various features and how it works.
Code Copy HideScrollFull
'Author : Amith Ellur'Date : 20 May 2003'Idea Conceived : Dr. Nitin ParanjapeOption Explicit
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)On Error GoTo Hell'holds the reference to ValueAdd subfolder in my personal foldersDim mValueAddFolder As MAPIFolder'holds the reference to a randomly selected folder with in "Of the day"Dim mRandomFolder As MAPIFolder'holds the reference to a randomly selected message from the randomly selected folderDim mRandomMessage As PostItem'the case sensitive folder structure expected is "Personal Folder->ValueAdd->Of the day".'With in the "Of the day" folder you can create multiple folder to categorize the content'I have Definition,Info, Murphy's Computer Law, Thought, Tip'So the header of the content becomes randomly selected folder name concatenated with " of the day" example "Murphy's Computer Law of the day"Set mValueAddFolder = Application.Session.Folders("Personal Folders").Folders("ValueAdd").Folders("Of the day")'this is the escape sequence for Subject EOM messages'if the subject contains #NVA i don't add the content'this is very useful when i send sms via email or one liner mail where the message ends in the subject <EOM>If InStr(Item.Subject, "#NVA ") = 0 Then'Mail format has to be HTML please set this on Tools->Options->Mail Format->Compose in this message format.'this check ensures i don't add the content while i reply the mail for the second timeIf InStr(Item.HTMLBody, "of the day") = 0 Then'processing needs to be done only if i have any subfolders in my "Of the day" folderIf mValueAddFolder.Folders.Count > 1 ThenSet mRandomFolder = mValueAddFolder.Folders(Int((mValueAddFolder.Folders.Count * Rnd) + 1))If mRandomFolder.Items.Count > 1 ThenSet mRandomMessage = mRandomFolder.Items(Int((mRandomFolder.Items.Count * Rnd) + 1))'just adding some format so that the content has a header and sending using HTML formatIf Trim(mRandomMessage.HTMLBody) = "" ThenItem.HTMLBody = Item.HTMLBody + "<P><B><FONT SIZE=2 FACE=Verdana>" + mRandomFolder.Name + " of the day...</FONT></B></P>" + mRandomMessage.BodyElseItem.HTMLBody = Item.HTMLBody + "<P><B><FONT SIZE=2 FACE=Verdana>" + mRandomFolder.Name + " of the day...</FONT></B></P>" + mRandomMessage.HTMLBodyEnd IfEnd IfEnd IfEnd IfElse'remove the escape sequence from the subject as it doesn't make any sense to the recieverItem.Subject = Replace(Item.Subject, "#NVA", "")End IfHell:End Sub
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)On Error GoTo Hell'holds the reference to ValueAdd subfolder in my personal foldersDim mValueAddFolder As MAPIFolder'holds the reference to a randomly selected folder with in "Of the day"Dim mRandomFolder As MAPIFolder'holds the reference to a randomly selected message from the randomly selected folderDim mRandomMessage As PostItem'the case sensitive folder structure expected is "Personal Folder->ValueAdd->Of the day".'With in the "Of the day" folder you can create multiple folder to categorize the content'I have Definition,Info, Murphy's Computer Law, Thought, Tip'So the header of the content becomes randomly selected folder name concatenated with " of the day" example "Murphy's Computer Law of the day"Set mValueAddFolder = Application.Session.Folders("Personal Folders").Folders("ValueAdd").Folders("Of the day")'this is the escape sequence for Subject EOM messages'if the subject contains #NVA i don't add the content'this is very useful when i send sms via email or one liner mail where the message ends in the subject <EOM>If InStr(Item.Subject, "#NVA ") = 0 Then'Mail format has to be HTML please set this on Tools->Options->Mail Format->Compose in this message format.'this check ensures i don't add the content while i reply the mail for the second timeIf InStr(Item.HTMLBody, "of the day") = 0 Then'processing needs to be done only if i have any subfolders in my "Of the day" folderIf mValueAddFolder.Folders.Count > 1 ThenSet mRandomFolder = mValueAddFolder.Folders(Int((mValueAddFolder.Folders.Count * Rnd) + 1))If mRandomFolder.Items.Count > 1 ThenSet mRandomMessage = mRandomFolder.Items(Int((mRandomFolder.Items.Count * Rnd) + 1))'just adding some format so that the content has a header and sending using HTML formatIf Trim(mRandomMessage.HTMLBody) = "" ThenItem.HTMLBody = Item.HTMLBody + "<P><B><FONT SIZE=2 FACE=Verdana>" + mRandomFolder.Name + " of the day...</FONT></B></P>" + mRandomMessage.BodyElseItem.HTMLBody = Item.HTMLBody + "<P><B><FONT SIZE=2 FACE=Verdana>" + mRandomFolder.Name + " of the day...</FONT></B></P>" + mRandomMessage.HTMLBodyEnd IfEnd IfEnd IfEnd IfElse'remove the escape sequence from the subject as it doesn't make any sense to the recieverItem.Subject = Replace(Item.Subject, "#NVA", "")End IfHell:End Sub
Content is too large so couldn't upload it leave me a comment with your email id and I will send you the .pst file.
2 comments:
HI Amith,
I was looking at "Add Value to mail" article, can u let me know the full content for this to work...
mailto: call_vishu@yahoo.com
Hi Amith,
Thanks for the great article. Could you please send me the .pst file on: milind_vakil@hotmail.com.
Thanks again !
Post a Comment