StartDownloadsServiceSamplesWorkshopsContact DeutschEnglish
 
Samples
General
Outlook®
 
Awarded by
Microsoft since 2005:
mvp logo
VBOffice Info
Visitors1768448
Impressions6631320
Links
Imprint
Privacy Policy
Contact
E-Mail: Determine a folder for sent items
Author: Michael BauerHomepage
Date: 24.04.2007Accessed: 35822
  
Description

Usually all emails are stored in the 'Sent Items' folder. You can change the folder via the email's options dialog - that would be a lot of manual work if you want to store all of your sent emails always in a different folder.

Sample #1 shows how to store all sent mails in a subfolder of the Inbox, called 'Ablage' (filing) - except the ones which shall be deleted after they are sent.

Sample #2 is slightly different: For every outgoing e-mail it displays a dialog to choose the folder from.

Sample #3 checks the name of the sending account and stores the email according to that in different, pre-determined subfolders of the Inbox. This sample works only from Outlook 2007 on!

' Variante #1
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("Ablage")
    Set Item.SaveSentMessageFolder = Subfolder
  End If
End Sub
' --------------------------------------------
' Variante #2
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  If TypeOf Item Is Outlook.MailItem Then
    Cancel = Not SaveSentMail(Item)
  End If
End Sub

Private Function SaveSentMail(Item As Outlook.MailItem) As Boolean
  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
      SaveSentMail = True
    End If
  End If
End Function
' --------------------------------------------
' Variante #3
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 "mvp"
      Set SubFolder = Inbox.Folders("ablage")
    Case "sample"
      Set SubFolder = Inbox.Folders("another sample folder")
    End Select

    If Not SubFolder Is Nothing Then
      Set Item.SaveSentMessageFolder = SubFolder
    End If
  End If
End Sub
 
 

ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the ... [more]

 

Access the master category list in the blink of an eye, share your categories in a network, get a reminder service, and ... [more]

 

SAM automatically sets the sender, signature, and folder for sent items, for instance based on the recipient ... [more]

 

OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or ... [more]