Solved

How do I set sent emails to specific folders?

Posted on 2008-10-14
7
291 Views
Last Modified: 2010-04-21
I know outlook has the ability to put sent emails in folders that you are replying from. What is a macro that will save ANY message (new messages, etc) in the CURRENTLY SELECTED folder?

I need the ability to save a sent message in the folder that is currently selected, no matter what or who I send it to.
0
Comment
Question by:Takamine334
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 22719191
Hi, Jason.

Outlook has a setting that does this for replies, but only replies.  Doing it for all items will require a bit of code like that below.  There are limitations to this though.  Every folder has a property called DefaultItemType that restricts the kind of items that can go in it.  A calendar folder can only contain appointments, a contacts folder only contacts, etc.  A calendar cannot contain a sent mail item and it's possible to send a message while viewing a calendar.  So, to avoid any errors, the code checks the current folder to see if it can hole a mail item.  If it can, then it saves the sent item there.  If not, then the sent item will go to Sent Items.  

This code must go in the ThisOutlookSession module.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim olkFolder As Outlook.MAPIFolder
    If Item.Class = olMail Then
        Set olkFolder = Application.ActiveExplorer.CurrentFolder
        Select Case olkFolder.DefaultItemType
            Case olMailItem, olPostItem
                Set Item.SaveSentMessageFolder = olkFolder
                Item.Save
        End Select
    End If
    Set olkFolder = Nothing
End Sub

Open in new window

0
 

Author Closing Comment

by:Takamine334
ID: 31506167
Thank you! You saved me SOOOO much hassle! I work with one other client and this will make our job a lot easier. Thank you!!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 22723897
No problem.  Always glad to help out.
0
RoboForm Secure Password Management System

RoboForm Everywhere - Superb Browser Support
Windows / Apple / IOS / Android / Linux / Chrome OS
Use different complex passwords everywhere
Best Secure Password Management by far
Synchronize all of your devices instantly
Safe, Secure & Highly Recommended!

 

Author Comment

by:Takamine334
ID: 22724011
I'm sorry to further complicate things. Is there a way to only run this code if the folder selected is in the BOOKING PST?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 22743513
No problem.  Try this.  Notice the comments in the code.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim olkFolder As Outlook.MAPIFolder
    If Item.Class = olMail Then
        Set olkFolder = Application.ActiveExplorer.CurrentFolder
        'Replace Booking with the name of the folder as it appears in Outlook folder view
        If RootFolder(olkFolder) = "Booking" Then
            Select Case olkFolder.DefaultItemType
                Case olMailItem, olPostItem
                    Set Item.SaveSentMessageFolder = olkFolder
                    Item.Save
            End Select
        End If
    End If
    Set olkFolder = Nothing
End Sub
 
Function RootFolder(olkFolder As Outlook.Folder) As String
    Dim olkStore As Outlook.Store
    Set olkStore = Session.GetStoreFromID(olkFolder.StoreID)
    RootFolder = olkStore.DisplayName
    Set olkStore = Nothing
End Function

Open in new window

0
 

Author Comment

by:Takamine334
ID: 22743762
Thank you so much!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 22743909
No problem.
0

Featured Post

SuperAntiSpyware Licenses Discounted by 25% !

Exclusive offer to Experts Exchange Members!
Buy SuperAntiSpyware License(s) from us and save 25% on the regular purchase price.
- Includes Full SuperAntiSpyware Vendor Support Entitlements
- Your Subscription does not begin until you activate your license
- Buy for your friends

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fraud Email 22 127
exchange , email 8 44
Bulk export PST files in MS Exchange 2016 2 79
Outlook Outbox Messages in Exchange 4 28
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question