Saving mail content when a mail is sent from Outlook

To save the content of a mail item when it is sent, here is the procedure.

Private WithEvents itms As Outlook.Items

Private WithEvents SntFldr As Outlook.Folder

SntFldr = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail)

itms = SntFldr.Items

Private Sub SaveMail() Handles itms.ItemAdd


End Sub

Before, I handled Application.Send Event and checked whether the Item is MailItem or not and then retrieved the content of that. But, with this, we couldn’t get the Date/Time and sending account information. So, opted for the above procedure.

UPDATE: Here is the updated sample code.

Private WithEvents SntFldr As Outlook.Folder
Private WithEvents itms As Outlook.Items
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
    SntFldr = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail)
    itms = SntFldr.Items
End Sub
Private Sub SaveMailAsMsg() Handles itms.ItemAdd
    If TypeOf itms.Item(itms.Count) Is Outlook.MailItem Then
        Dim olMail As Outlook.MailItem = itms.Item(itms.Count)
        MessageBox.Show("Item Added. " & vbCrLf & "Subject: " & olMail.Subject & vbCrLf & "From: " & olMail.SenderEmailAddress)
    End If
End Sub

Hope this helps!


  1. Hey,
    Can you please add more detail on the section above. I have been looking for something to save a copy of a sent email and cant find anything. This is the closest but dont fully understand it.

  2. I have a vsto add in that when i clich on a file on my inbox i csn save it to a .msg.
    iwant to be able to do the same bit as soon as i send an email i want that email to be saved on my pc in a directory as aj .msg file.
    i have been looking for a solution for months an no one can help ot would be beyond awesome if you had a solution.
    many thanks

      1. Hi,
        Still having trouble to do what i am trying to get to. Your code works fine with the send event and pops up with the MsgBox.
        What I have done in my little app is to have a dialog box pop up asking the user do you want to save this email. Yes/No. If Yes is clicked then a new dialog opens where the user can select a location to save the email. (I will look in alternative saving formats later, thanks for the link on that)
        So, when I have an item selected its easy because the “Selected Item” is the active item to save, but when you send one the selected item is still the item that has been selected last.
        So in my Add_In on start I have a command bar that is added with a single button. If clicked you can save a selected item. On the send event it brings up the dialog in the send even.
        But then when I get to the Actual dialog to save the email in my location and trying to Identify the last sent item (or item that has just been sent) is what I cant figure out how to do. 🙁
        Thanks again for the help!!! Apprecaite it a lot.

  3. That’s what I have done in the code. itms.Item(itms.Count) gives you the last (latest) item in the Sent Items Folder.
    You just comment MessageBox line and write what ever you want. It will server your purpose.

  4. Hi Pranav
    You itms.Item(itms.Count) gives you the last item in the sent items folder. Is this same in Outlook 2003 Standard Ed SP3 and Outlook 2003 Professional Ed Sp2?

Leave a Comment

Your email address will not be published. Required fields are marked *