VBOffice

Determine a Folder for Sent Items

Get some samples for how to save a sent message in another folder than the default Sent Items folder.

Last modified: 2017/10/27 | Accessed: 109.802  | #54
◀ Previous sample Next sample ▶

Content

SAM SAM
Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.

Save Email in a Subfolder of the Inbox

By default, all emails are stored in the 'Sent Items' folder. You can change the folder manually via the Options dialog of a message. However, if you want to save all messages in a different folder, you need a macro if you don't want to set the folder manually for each message.

The first sample stores all sent emails, except those you want to delete, in a subfolder of the inbox, which is called 'File'.


tip  How to add macros to Outlook
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  If TypeOf Item Is Outlook.MailItem Then
    SaveSentMail Item
  End If
End Sub

Private Sub SaveSentMail(Item As Outlook.MailItem)
  Dim Inbox As Outlook.MAPIFolder
  Dim Subfolder As Outlook.MAPIFolder

  If Item.DeleteAfterSubmit = False Then
    Set Inbox = Application.Session.GetDefaultFolder(olFolderInbox)
    Set Subfolder = Inbox.Folders("File")
    Set Item.SaveSentMessageFolder = Subfolder
  End If
End Sub

Pick the Folder Manually

This sample displays the folder picker for each outgoing email. Press Cancel on the dialog if you want to store the message in the default folder.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  If TypeOf Item Is Outlook.MailItem Then
    SaveSentMail Item
  End If
End Sub

Private Sub SaveSentMail(Item As Outlook.MailItem) 
  Dim F As Outlook.MAPIFolder

  If Item.DeleteAfterSubmit = False Then
    Set F = Application.Session.PickFolder
    If Not F Is Nothing Then
      Set Item.SaveSentMessageFolder = F
    End If
  End If
End Sub
Category-Manager Category-Manager
With Category-Manager you can group your Outlook categories, share them with other users, filter a folder by category, automatically categorize new emails, and more. You can use the Addin even for IMAP.

File Depending on the Sending Account

This sample checks the name of the sending account and saves the sent message in a determined subfolder of the inbox. Add as many Cases as you need, and add the names of your accounts and the names of the subfolders.

This sample works only for Outlook 2007 and higher.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  If TypeOf Item Is Outlook.MailItem Then
    SaveSentMail Item
  End If
End Sub

Private Sub SaveSentMail(Item As Outlook.MailItem)
  Dim Inbox As Outlook.Folder
  Dim SubFolder As Outlook.Folder

  If Item.DeleteAfterSubmit = False Then
    Set Inbox = Application.Session.GetDefaultFolder(olFolderInbox)

    Select Case LCase$(Item.SendUsingAccount.DisplayName)
    Case "Account_1"
      Set SubFolder = Inbox.Folders("Folder_1")
    Case "Account_2"
      Set SubFolder = Inbox.Folders("Folder_2")
    End Select

    If Not SubFolder Is Nothing Then
      Set Item.SaveSentMessageFolder = SubFolder
    End If
  End If
End Sub
ReplyAll ReplyAll
ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.
email  Send a message