Outlook 2007 : how to choose Sent directory *each time* I send a directory?

Hi there,

I read this http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_22918966.html
But I don't think it's exactly what I'm looking for.

=> I'm looking for something to make me choose where to store an e-mail right after it's been sent. something like a popup showing my exchange account's directory hierarchy.
I'm using this a lot with Thunderbird, via the a plugin called "Copy Sent to Current", to organize my e-mails, including the ones I send. https://addons.mozilla.org/en-US/thunderbird/addon/2561

Is there any plugin or macro code I could use to do this ?

(default would be to store in the usual Sent folder)

Thank you
Who is Participating?
Patrick MatthewsConnect With a Mentor Commented:

OK, the info that you are using the French version may have been the breakthrough we needed.  I went back
to the Application_ItemSend sub in the ThisOutlookSession module, and changed this line:

                If arr(0) = "Inbox" Then


                If arr(0) = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Name Then

That makes the code language independent, which it wasn't before.  The new code seems to work for me;
I'm crossing my fingers for you :)


Patrick MatthewsCommented:
Hello mchkorg,

I was able to get this working in Outlook 2003.  It will prompt you what folder to save outgoing mail messages
in, including an option not to save at all.  It will include the following:

do not save
Sent Items

To implement:

1) Download zip file from here...

View all files for Question ID: 24408054

Direct link to your file

2) Extract files to desktop

3) Go to VB Editor and import class module ThisOutlookSession.cls

4) Import userform frmSaveToFolder.frm

5) Make sure macro security is not set to High

Now, when you send a MailItem, you should get prompted about where to save the item.


mchkorgAuthor Commented:
I'll try to test this tomorrow (I'm running out of time right now)
Can you make it choose a directory "outside" Sent items ?
I've got a whole directory structure outside Sent items, of course, and this is where I'd like to store my sent e-mails

In my projects sub-dirs, let say

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Patrick MatthewsCommented:

I updated the objects.  View all files for Question ID: 24408054

Direct link to your file

It now will show a list of all folders/subfolders in Sent Items and Inbox, and will drill down to all descendants.


mchkorgAuthor Commented:
Sorry I might be stupid with outlook macros :)

I imported both elements (I can see them on the left part of the VB editor)
I quit outlook, it asked me to save ThisOutlookSession, which I did, then restarted it
I still can send e-mails, but nothing happens :)
I tried to set the macro security to the lowest level (no security control), nothing changes

Or it's all about OL 2007 VS 2003?

Any idea?

Thank you
Patrick MatthewsCommented:

You should definitely only have one copy of each, so try removing all of the items related to this and reimporting
the updated objects.

I do not have OL2007 on my machine to test with.  The code should be compatible, but it is possible that there
is still some security setting that must be updated.  If there is no reply from other Experts within the next few
hours, I suggest you click the 'request attention' link and ask the Mods to try and draw in some additional


mchkorgAuthor Commented:
One copy of each... what?
I imported only your 2nd code version, once.
About security stuff, I can't say. Except the basic setting allowing or not none/signed/all macros

Patrick MatthewsCommented:
WhackAMod (and other Experts/Mods who may see this),

The objects provided in comment 24415802 are working perfectly in my own installation of Outlook 2003.
IMHO, this question is answered.


mchkorgAuthor Commented:
I'm sure it's working in OL2003.
Problem is I'm using OL 2007, it's written in the title
There must be some difference somewhere, I can't figure out which ones.

IMHO, the question's not answered
And if it's just a problem of macro security (I already check), that kind of stuff, if someone finds the solution, I will of course give points to everyone involved, especially for the one who wrote that big macro, you.

David LeeCommented:
Hi, guys.

I just used Outlook 2007 to test the code matthewspatrick posted.  It worked perfectly.  Let's try a slightly different approach to setting this up in Outlook.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  If there is more than one module called ThisOutlookSession, then stop and let me know
5.  If there is only one ThisOutlookSession module, then double-click on it
6.  If the code mattewspartrick provided is the only code in the module, then delete it all.  If you have any other code in the module, then delete the Application_ItemSend subroutine
7.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
8.  Click File > Import File
9.  Navigate to the file system folder where you saved the files you unzipped from the ZIP file you downloaded from eeStuff
10.  Select the file frmSaveToFolder.frm and click Open.  DO NOT import the file named ThisOutlookSession.cls
11.  Click the diskette icon on the toolbar to save the changes
12.  Close the VB Editor
13.  Click Tools > Trust Center
14.  Click Macro Security
15. Set Macro Security to "Warnings for all macros"
16. Click OK
17. Close Outlook
18. Start Outlook.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

Test the code and let us know what happens.

Option Explicit
Option Compare Text
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim mf As MAPIFolder
    If Item.Class = olMail Then
        With frmSaveToFolder
            Select Case .cbFolders.Value
                Case "<do not save>"
                    Item.DeleteAfterSubmit = True
                Case "Sent Items"
                    Item.DeleteAfterSubmit = False
                    Set Item.SaveSentMessageFolder = _
                Case Else
                    Item.DeleteAfterSubmit = False
                    Set Item.SaveSentMessageFolder = _
            End Select
        End With
        Unload frmSaveToFolder
    End If
End Sub

Open in new window

Patrick MatthewsCommented:
BlueDevilFan said:
>>I just used Outlook 2007 to test the code matthewspatrick posted.  It worked perfectly.

Thanks for checking this, BDF!  I thought it would work, but I could not test it fully.  (No one cares that I
have Excel 2007 and the other Office 2007 components installed, bu the company standard is still
Outlook 2003 and the help desk will just laugh at me if I ever run into an issue.)


David LeeCommented:
You're welcome, Patrick.  Maybe you could talk the IT folks into letting you run a virtual machine solution so you have both versions of Outlook.
mchkorgAuthor Commented:

Thank you for this-by-step procedure.
It's almost working now - I tried Patrick's code and yours, here is what I get:
- when I send with a copy to Sent Items => OK
- when I send with no copy => OK
- when I choose a directory, I have an error

If using Patrick's code, the debugger points me to:
- Set mf = mf.Folders(arr(Counter))

If using yours, it points to:
- Application.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail).Folders(.cbFolders.Value)

I'm using a french Outlook, I'd bet there's something with the default inbox french name : Boîte de Réception - because of î & é
My subdirectoris in "Boîte de Réception" may have accents or not. I tried both.
I also tried to use a subdir created in the mailbox (not inbox), I can't see it.

Any idea to debug this ?
David LeeCommented:
"Thank you for this-by-step procedure."
You're welcome.

"I tried Patrick's code and yours"
The code is all Patrick's.  I copied and pasted a portion of the code to avoid importing it.  
What are the errors you get?  I assume that the code doesn't appear twice, right?  Also, are you selecting a folder or typing in the name of a folder that doesn't appear in the list?  If the latter, then that is what's causing the errors.

"I also tried to use a subdir created in the mailbox (not inbox), I can't see it."
The solution only lists files that occur under Sent Items.  It does not list folders from elsewhere in the mailbox.
Patrick MatthewsCommented:

BTW, I did also test using accented characters, creating a subfolder under my Inbox named "Acçénted".
It did not seem to mind the special characters one bit :)


mchkorgAuthor Commented:
Ok, the code modification did the trick.
Every situation is working now (sent item / do not save / somewhere else)

> "The solution only lists files that occur under Sent Items.  It does not list folders from elsewhere in the mailbox."
The subdirs are not under "Sent Items", see attached image. But they're listed and usable. Maybe I don't understand what you mean with "under Sent items"

Anyway, many thanks

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.