Outlook: Search Subject to Find Last email in Sent Folder and Copy Body to New email RRS feed

  • Question

  • Hi All!

    I send a daily status email.  I created an Outlook from, macro and custom ribbon icon to pop open a pre-populated, pre-formatted email in which I enter content.  I add text and send the new email.  Works great.

    Evolution:  I wish to pre-populate the next day's email with the last day's email body content--to save a small bit of typing.  So, I wish to search my sent folder for the last email I sent (searching the subject for a text string, for example) to grab the last email's body text to pre-populate the next day's email.  I am open to other approaches...

    I can only do basic VBA, and could use an assist on this one.  Many thanks in advance!

    Signed, "Not-Yet-The-Outlook-Guru"

    • Edited by AllenGC Friday, March 28, 2014 11:43 PM
    Friday, March 28, 2014 11:35 PM


  • Hello Allen,

    First of all, please remember that the Sent mail folder can be represented by any folder. The MailItem class from the Outlook object model allows you to specify the SaveSentMessageFolder property which represent the folder where the sent mail item will be stored. For example:

    Sub SetSentFolder()  
     Dim myItem As Outlook.MailITem  
     Dim myResponse As Outlook.MailITem  
     Dim mpfInbox As Outlook.Folder  
     Dim mpf As Outlook.Folder 
     Set mpfInbox = Application.Session.GetDefaultFolder(olFolderInbox)  
     Set mpf = mpfInbox.Folders.Add("SaveMyPersonalItems")  
     Set myItem = Application.ActiveInspector.CurrentItem  
     Set myResponse = myItem.Reply  
     myResponse.To = "Dan Wilson"  
     Set myResponse.SaveSentMessageFolder = mpf  
    End Sub

    Typically you can get the default Sent Items folder using the GetDefaultFolder method of the Namespace class. For example:

    Sub DisplaySentMailFolder()  
     Dim myNamespace As Outlook.NameSpace  
     Dim mySentMail As Outlook.Folder  
     Dim myFolder As Outlook.Folder
     Set myNamespace = Application.GetNamespace("MAPI")  
     Set mySentMail = myNamespace.GetDefaultFolder(olFolderSentMail)  
     Set myFolder = myTasks.Folders(1)  
    End Sub

    Then you can use the Items property of the Folder class to access the items list. The Items class provides the GetFirst and GetLast methods that return the first and last items in the collection. But if you want to find a specific e-mail you need to use the Find/FindNext or Restrict methods of the Items collection.

    Saturday, March 29, 2014 12:08 PM