How to Auto Save Specific Sent Emails to a Specific Folder with Outlook VBA

By default, Outlook will save the sent emails in the “Sent Items” folder. If you don’t want to save the specific sent mails in the default folder, you can employ the method introduced in this article.

Some users want to automatically save some sent emails to the specified folder instead of saving them in the default “Sent Items” folder. Thus many resort to the Outlook rule, which offers a similar action – “move a copy to the specified folder”, shown as the following screenshot. However, by this means, actually, the original sent email is still saved in “Sent Items” folder. Only a copy of the sent email gets moved to the specified folder. Apparently, this feature cannot fulfill the real needs.Create a Rule to Auto Move a Copy to the specified folder

Of course, users can manually specify a non-default folder to save the sent email. Just go to the “Options” tab and click on “Save Sent Item to” > “Other Folder”. But this approach will be troublesome since users have to manually specify the folder every time.Save Sent Item to Other Folder Manually

Now that both means mentioned above are not efficient, why not recur to the Outlook VBA? Here are the concrete codes and steps to auto save the specific sent emails to a specific folder.

Auto Save Specific Sent Emails to a Specific Folder

  1. To start with, launch Outlook application.
  2. Then you ought to press “Alt + F11” key buttons, which will help you access the VBA editor window.
  3. In the popup “Microsoft Visual Basic for Applications” window, you can find and double click on “ThisOutlookSession” project in the left side.
  4. Next in the open “ThisOutlookSession” project window, you should copy the following VBA codes into it.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim SentFolder As Folder
    Dim desFolder As Folder
 
    If TypeName(Item) = "MailItem" And Item.DeleteAfterSubmit = False Then
       'Specify the sent emails
       If InStr(Item.To, "shirley") > 0 Or InStr(LCase(Item.Subject), "test") > 0 Then
          'Specify the folder for saving the sent emails
          'You can change it as per your needs
          Set SentFolder = Application.Session.GetDefaultFolder(olFolderSentMail)
          Set desFolder = SentFolder.Folders("Test")
          Set Item.SaveSentMessageFolder = desFolder
       End If
    End If
End Sub

VBA Codes - Auto Save Specific Sent Emails to a Specific Folder

  1. Subsequently, you should sign this code and adjust your Outlook macro level to low.
  2. Finally, you can exit the current window. From now on, the specific sent mails will be automatically saved to the specified mail folder.

Extra Tip: Display the “Select Folder” Dialog Box When Sending

There are some people who would like to manually select the mail folder to save the sent emails. But always going to “Option” tab to select folder will be messy. In this case, they wish that Outlook can auto display the “Select Folder” dialog box when sending. In response to this requirement, here are another VBA codes. You can copy it to “ThisOutlookSession” project.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim desFolder As Folder
 
    If TypeName(Item) = "MailItem" And Item.DeleteAfterSubmit = False Then
       'specify the email
       If InStr(Item.To, "shirley") > 0 Or InStr(LCase(Item.Subject), "test") > 0 Then
          'Display the “Select Folder” dialog box
          Set desFolder = Application.Session.PickFolder
          Set Item.SaveSentMessageFolder = desFolder
       End If
    End If
End Sub

VBA Codes - Auto Display the “Select Folder” Dialog Box When Sending

From now on, every time you finish an email and click “Sent” button, the “Select Folder” dialog box will pop up automatically, like the image below. At that point, you can specify the folder to save the current sent email.Select Folder Dialog Box

Repair Outlook

Outlook earns a lot of kudos for its multiple functions. Nevertheless, it’s due to richness in feature that Outlook is quite vulnerable. Also, malicious email is one of the most potential threats to Outlook data. Therefore, as regular Outlook users, you’d better get hold of a preeminent Outlook PST mail fix tool, like DataNumen Outlook Repair. Thereby, you can quickly resolve various Outlook errors and keep your Outlook data well-protected.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair corrupted SQL Server mdf and outlook repair software products. For more information visit www.datanumen.com

One response to “How to Auto Save Specific Sent Emails to a Specific Folder with Outlook VBA”

  1. How do you exclude email from calendar invite responses? or can these be sorted too? Right now I get an error 438 on these emails.

Leave a Reply

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