Monday, July 16, 2007

How to Choose your own Location of Sent Mails in Outlook?

Once you've sent out an e-mail, the default location for it to be saved is under Sent Items. The following tip explains how to use Microsoft's Visual Basic Editor to teach Outlook to ask where you want to save an e-mail once it's been sent.

  1. In Outlook, click to Tools > Macro > Visual Basic Editor (or press F11)
    Note: You may see a pop-up Security Warning telling you "'ThisOutlookSession' contains macros". Select Enable Macros.
  2. Double-click the Project icon > Microsoft Office Outlook Objects, then double-click ThisOutlookSession. Paste the code below into the text box. Click File > Save.



Private Sub Application_ItemSend(ByVal Item As Object, _
Cancel As Boolean)
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objAttFld As MAPIFolder
Set objNS = Application.GetNamespace("MAPI")
If Item.Class = olMail Then
Set objFolder = objNS.PickFolder
If TypeName(objFolder) <> "Nothing" And _
IsInDefaultStore(objFolder) Then
Set Item.SaveSentMessageFolder = objFolder
End If
Item.UnRead = False
Set objFolder = Nothing
Set objNS = Nothing
Set objAttFld = Nothing
End If
End Sub
Public Function IsInDefaultStore(objOL As Object) As Boolean
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objInbox As Outlook.MAPIFolder
On Error Resume Next
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Select Case objOL.Class
Case olFolder
If objOL.StoreID = objInbox.StoreID Then
IsInDefaultStore = True
End If
Case olAppointment, olContact, olDistributionList, _
olJournal, olMail, olNote, olPost, olTask
If objOL.Parent.StoreID = objInbox.StoreID Then
IsInDefaultStore = True
End If
Case Else
MsgBox "This function isn't designed to work " & _
"with " & TypeName(objOL) & _
" items and will return False.", _
, "IsInDefaultStore"
End Select
Set objApp = Nothing
Set objNS = Nothing
Set objInbox = Nothing
End Function


Note: If you have any problems, simply delete the pasted text in Visual Basic Editor or disable macros when prompted.

No comments:

Post a Comment