Link to home
Start Free TrialLog in
Avatar of mchkorg
mchkorgFlag for France

asked on

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

Hi there,

I read this https://www.experts-exchange.com/questions/22918966/How-do-I-automate-an-Outlook-2007-Rule-to-move-Sent-Items-from-the-default-location-to-a-shared-mailbox's-sent-items.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
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

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
https://filedb.experts-exchange.com/incoming/ee-stuff/7638-SaveToFolder.ziphttps://filedb.experts-exchange.com/incoming/ee-stuff/7640-SaveToFolder.zip
 

Direct link to your file
https://filedb.experts-exchange.com/incoming/ee-stuff/7638-SaveToFolder.zip 

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.

Regards,

Patrick
Avatar of mchkorg

ASKER

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

Regards
mchkorg,

I updated the objects.  View all files for Question ID: 24408054
https://filedb.experts-exchange.com/incoming/ee-stuff/7638-SaveToFolder.ziphttps://filedb.experts-exchange.com/incoming/ee-stuff/7640-SaveToFolder.zip
 

Direct link to your file
https://filedb.experts-exchange.com/incoming/ee-stuff/7640-SaveToFolder.zip 

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

Regards,

Patrick
Avatar of mchkorg

ASKER

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
mchkorg,

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
Experts.

Regards,

Patrick
Avatar of mchkorg

ASKER

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

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.

Cheers,

Patrick
Avatar of mchkorg

ASKER

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.

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
            .Show
            Select Case .cbFolders.Value
                Case "<do not save>"
                    Item.DeleteAfterSubmit = True
                Case "Sent Items"
                    Item.DeleteAfterSubmit = False
                    Set Item.SaveSentMessageFolder = _
                        Application.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail)
                Case Else
                    Item.DeleteAfterSubmit = False
                    Set Item.SaveSentMessageFolder = _
                        Application.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail).Folders(.cbFolders.Value)
            End Select
        End With
        Unload frmSaveToFolder
    End If
    
End Sub

Open in new window

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.)

Cheers,

Patrick
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.
Avatar of mchkorg

ASKER

Hi,

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 ?
"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.
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
mchkorg,

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 :)

Regards,

Patrick
Avatar of mchkorg

ASKER

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

20090603-080544.png