View Full Version : Solved: Outlook Sent Mail Folder
kenburenga
11-30-2010, 07:58 PM
I am trying to write a Macro that saves outgoing e-mail to my “FollowUp” folder instead of my “Sent Items”. The Macro is to be run after opening and composing a New E-mail message, but before it is sent.
My code is as follows.
Sub Folder()
Set objMail = Application.ActiveInspector.CurrentItem
Dim myNamespace As NameSpace
Dim objFolder As MAPIFolder
Set myNamespace = Application.GetNamespace("MAPI")
Set objFolder = myNamespace.Folders("FollowUp")
Set Item.SaveSentMessageFolder = objFolder
Set myNamespace = Nothing
Set objFolder = Nothing
End Sub
The code halts on
Set objFolder = myNamespace.Folders("FollowUp")
with “An object could not be found” message.
Can someone please help me solve this.
JP2112
12-01-2010, 05:01 AM
Please use code tags, it makes reading your code much easier.
In relation to your Inbox, where is the FollowUp folder located?
kenburenga
12-01-2010, 07:37 AM
JP2112 -
FollowUp is a folder at the same level as the Inbox, Sent Items, Drafts, etc.
Please explain code tags, I'm new at this.
Thank for your help.
Best regards, KenB
Charlize
12-01-2010, 08:32 AM
In the thisoutlooksession area, you can add this code :
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If Item.Class = olMail Then
If MsgBox("Follow-up or not ?", vbYesNo, "Follow upper ...") = vbYes Then
MsgBox "code to copy mail to my follow up folder."
Else
MsgBox "don't do a thing."
End If
End If
End Subthe code inside the application_send procedure.
Charlize
kenburenga
12-01-2010, 08:54 AM
Charlize -
Thanks, but I don't want to be queried. I just want to click on the Macro and have it change the SaveSendMessageFolder to FollowUp instead to Sent Items.
JP2112
12-01-2010, 11:51 AM
In the post editor, there's a button marked "VBA". Highlight your code and click the button to surround code in code tags.
Try this:
Set objFolder = myNamespace.GetDefaultFolder(olFolderInbox).Parent.Folders("FollowUp")
kenburenga
12-01-2010, 12:30 PM
Thanks JP.
Now my code below stops on the line
Set Item.SaveSentMessageFolder = objFolder saying an object is required.
I tried changing that line to
Set SaveSentMessageFolder = objFolder. The Macro runs, but the outgoing message still goes in the Sent Items folder.
What next?
Sub Folder()
Set objMail = Application.ActiveInspector.CurrentItem
Dim myNamespace As NameSpace
Dim objFolder As MAPIFolder
Set myNamespace = Application.GetNamespace("MAPI")
Set objFolder = myNamespace.GetDefaultFolder(olFolderInbox).Parent.Folders("FollowUp")
Set Item.SaveSentMessageFolder = objFolder
Set myNamespace = Nothing
Set objFolder = Nothing
End Sub
kenburenga
12-01-2010, 12:40 PM
JP -
Go it working! I changed the line to.
Set objMail.SaveSentMessageFolder = objFolder
Thanks for your help!!!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.