Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Problem with : SaveSentMessageFolder (http://www.outlookbanter.com/outlook-vba/14444-problem-savesentmessagefolder.html)

Nader May 11th 06 09:36 PM

Problem with : SaveSentMessageFolder
 
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



Eric Legault [MVP - Outlook] May 11th 06 10:46 PM

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

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Nader" wrote:

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




Sue Mosher [MVP-Outlook] May 11th 06 10:55 PM

Problem with : SaveSentMessageFolder
 
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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Nader" wrote in message ...
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



Nader May 12th 06 12:26 PM

Problem with : SaveSentMessageFolder
 
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]" a écrit dans le message
de news: ...
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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Nader" wrote in message
...
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





Sue Mosher [MVP-Outlook] May 12th 06 01:21 PM

Problem with : SaveSentMessageFolder
 
Did you put that code in the ThisOutlookSession module? Does other VBA code run?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Nader" wrote in message ...
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 ?



Nader May 12th 06 03:33 PM

Problem with : SaveSentMessageFolder
 
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]" a écrit dans le message
de news: ...
Did you put that code in the ThisOutlookSession module? Does other VBA code
run?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Nader" wrote in message
...
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 ?




Sue Mosher [MVP-Outlook] May 12th 06 03:40 PM

Problem with : SaveSentMessageFolder
 
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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Nader" wrote in message ...
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]" a écrit dans le message
de news: ...
Did you put that code in the ThisOutlookSession module? Does other VBA code
run?



"Nader" wrote in message
...
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 ?




Nader May 12th 06 04:14 PM

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

"Sue Mosher [MVP-Outlook]" a écrit dans le message
de news: ...
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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Nader" wrote in message
...
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]" a écrit dans le
message
de news: ...
Did you put that code in the ThisOutlookSession module? Does other VBA
code
run?



"Nader" wrote in message
...
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 ?






Nader May 12th 06 04:28 PM

Problem with : SaveSentMessageFolder
 
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" a écrit dans le message de news:
...
i did and it dosen't work as well. I don't understand why ?

"Sue Mosher [MVP-Outlook]" a écrit dans le
message de news: ...
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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Nader" wrote in message
...
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]" a écrit dans le
message
de news: ...
Did you put that code in the ThisOutlookSession module? Does other VBA
code
run?



"Nader" wrote in message
...
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 ?








Sue Mosher [MVP-Outlook] May 15th 06 04:14 PM

Problem with : SaveSentMessageFolder
 
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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Nader" wrote in message ...
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" a écrit dans le message de news:
...
i did and it dosen't work as well. I don't understand why ?

"Sue Mosher [MVP-Outlook]" a écrit dans le
message de news: ...
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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Nader" wrote in message
...
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]" a écrit dans le
message
de news: ...
Did you put that code in the ThisOutlookSession module? Does other VBA
code
run?



"Nader" wrote in message
...
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 ?









All times are GMT +1. The time now is 12:58 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com