Problem with : SaveSentMessageFolder

N

Nader

Hello,

I'm using outlook 2002 with Exchange server and I'm trying to change my code
using vba the default folder where the sent item are saved to a folder which
is on a public folder.

My code works great when the folder is on my mailbox but when the folder is
located on the network I get a message from outlook saying : "The Operation
failed".

Does anyone know why and how I can make it work ?

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

' Set the NameSpace object.
Set olns = Item.Application.GetNamespace("MAPI")

' MyFolder is a variant variable whose subtype is "object" since a Set
statement is used.
Set MyMailbox = olns.Folders("Public Folders")
Set MyFolder1 = MyMailbox.Folders("All Public Folders")
Set MyFolder2 = MyFolder1.Folders("Important")
Set MyFolder3 = MyFolder2.Folders("Document")

' Correctly sets the folder where the "sent item" will be stored.
Set Item.SaveSentMessageFolder = MyFolder


Item.SaveSentMessageFolder = MyFolder

End Sub
 
E

Eric Legault [MVP - Outlook]

Just checking: do you have Author permissions on that Public Folder and is it
a Mail or Post Items folder?
 
S

Sue Mosher [MVP-Outlook]

The SaveSentMessageFolder property supports only folders in your mailbox. If you want to put an item in a public folder, either Bcc the folder's email address and set DeleteAfterSubmit = True or subscribe to the ItemAdd event on the Sent Items folder's Items collection, rather than using ItemSend.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
N

Nader

Hello Sue,

I took this code from your website :

Dim WithEvents colSentItems As Items

Private Sub Application_Startup()
Dim NS As Outlook.NameSpace
Set NS = Application.GetNamespace("MAPI")
Set colSentItems = NS.GetDefaultFolder(olFolderSentMail).Items
Set NS = Nothing
End Sub

Private Sub colSentItems_ItemAdd(ByVal Item As Object)
If Item.Class = olMail Then
MsgBox "Hello Nader"
Item.Save
End If
End Sub

and tried it on outlook 2002 but nothing happens.

What could be wrong ?

thanks in advance.


"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le message
de news: (e-mail address removed)...
The SaveSentMessageFolder property supports only folders in your mailbox. If
you want to put an item in a public folder, either Bcc the folder's email
address and set DeleteAfterSubmit = True or subscribe to the ItemAdd event
on the Sent Items folder's Items collection, rather than using ItemSend.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

Did you put that code in the ThisOutlookSession module? Does other VBA code run?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
N

Nader

Yes, I did and I put a msgbox inside the Application_Startup() to see if
this sub is executed when I open outlook and it does.

But the rest of the code is not executed (i've put breakpoint in different
places)

Thanks again.

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le message
de news: (e-mail address removed)...
Did you put that code in the ThisOutlookSession module? Does other VBA code
run?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

I can't explain why the ItemAdd event wouldn't fire. It might be worth setting up a similar event handler for your Inbox to see if it works.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Nader said:
Yes, I did and I put a msgbox inside the Application_Startup() to see if
this sub is executed when I open outlook and it does.

But the rest of the code is not executed (i've put breakpoint in different
places)

Thanks again.

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le message
de news: (e-mail address removed)...
Did you put that code in the ThisOutlookSession module? Does other VBA code
run?
 
N

Nader

i did and it dosen't work as well. I don't understand why ?

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le message
de news: (e-mail address removed)...
I can't explain why the ItemAdd event wouldn't fire. It might be worth
setting up a similar event handler for your Inbox to see if it works.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Nader said:
Yes, I did and I put a msgbox inside the Application_Startup() to see if
this sub is executed when I open outlook and it does.

But the rest of the code is not executed (i've put breakpoint in different
places)

Thanks again.

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le
message
de news: (e-mail address removed)...
Did you put that code in the ThisOutlookSession module? Does other VBA
code
run?
 
N

Nader

Sue,

I've tried the code on a standalone pc without exchange server and it works
great... I'm totally confused!

thanks again for ur precious help.

Nader said:
i did and it dosen't work as well. I don't understand why ?

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le
message de news: (e-mail address removed)...
I can't explain why the ItemAdd event wouldn't fire. It might be worth
setting up a similar event handler for your Inbox to see if it works.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Nader said:
Yes, I did and I put a msgbox inside the Application_Startup() to see if
this sub is executed when I open outlook and it does.

But the rest of the code is not executed (i've put breakpoint in
different
places)

Thanks again.

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le
message
de news: (e-mail address removed)...
Did you put that code in the ThisOutlookSession module? Does other VBA
code
run?
 
S

Sue Mosher [MVP-Outlook]

Maybe this is part of the issue: ItemAdd and ItemChange will not fire if more than 16 items arrive or change at one time. (This is a well documented limitation of these events.)

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Nader said:
Sue,

I've tried the code on a standalone pc without exchange server and it works
great... I'm totally confused!

thanks again for ur precious help.

Nader said:
i did and it dosen't work as well. I don't understand why ?

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le
message de news: (e-mail address removed)...
I can't explain why the ItemAdd event wouldn't fire. It might be worth
setting up a similar event handler for your Inbox to see if it works.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Nader said:
Yes, I did and I put a msgbox inside the Application_Startup() to see if
this sub is executed when I open outlook and it does.

But the rest of the code is not executed (i've put breakpoint in
different
places)

Thanks again.

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le
message
de news: (e-mail address removed)...
Did you put that code in the ThisOutlookSession module? Does other VBA
code
run?
Hello Sue,

I took this code from your website :

Dim WithEvents colSentItems As Items

Private Sub Application_Startup()
Dim NS As Outlook.NameSpace
Set NS = Application.GetNamespace("MAPI")
Set colSentItems = NS.GetDefaultFolder(olFolderSentMail).Items
Set NS = Nothing
End Sub

Private Sub colSentItems_ItemAdd(ByVal Item As Object)
If Item.Class = olMail Then
MsgBox "Hello Nader"
Item.Save
End If
End Sub

and tried it on outlook 2002 but nothing happens.

What could be wrong ?
 
N

Nader

i have rewritten the code from the very begining and it's now working.

thanks for your help.

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le message
de news: (e-mail address removed)...
Maybe this is part of the issue: ItemAdd and ItemChange will not fire if
more than 16 items arrive or change at one time. (This is a well documented
limitation of these events.)

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Nader said:
Sue,

I've tried the code on a standalone pc without exchange server and it
works
great... I'm totally confused!

thanks again for ur precious help.

Nader said:
i did and it dosen't work as well. I don't understand why ?

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le
message de news: (e-mail address removed)...
I can't explain why the ItemAdd event wouldn't fire. It might be worth
setting up a similar event handler for your Inbox to see if it works.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Nader said:
Yes, I did and I put a msgbox inside the Application_Startup() to see if
this sub is executed when I open outlook and it does.

But the rest of the code is not executed (i've put breakpoint in
different
places)

Thanks again.

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le
message
de news: (e-mail address removed)...
Did you put that code in the ThisOutlookSession module? Does other VBA
code
run?
Hello Sue,

I took this code from your website :

Dim WithEvents colSentItems As Items

Private Sub Application_Startup()
Dim NS As Outlook.NameSpace
Set NS = Application.GetNamespace("MAPI")
Set colSentItems = NS.GetDefaultFolder(olFolderSentMail).Items
Set NS = Nothing
End Sub

Private Sub colSentItems_ItemAdd(ByVal Item As Object)
If Item.Class = olMail Then
MsgBox "Hello Nader"
Item.Save
End If
End Sub

and tried it on outlook 2002 but nothing happens.

What could be wrong ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top