none
Outlook 2007 Addin - Sent messages lost in ONLINE mode RRS feed

  • Question

  • Hi,  we have an Outlook 2007 VSTO addin.  It has an alternative send button which displays a dialog box with certain folders in which the user can 'file' a copy of the sent message.  It all works very well in CACHED mode.  However, in ONLINE mode which we have in our Citrix environment, if the user is a delegate for another user (sending on behalf of), the copies of the sent messages don't appear anywhere.

    The addin's code sets the  MailItem.SaveSentMessageFolder.InAppFolderSyncObject = True.  Then the code sets the MailItem.SaveSentMessageFolder to the user-selected folder.

    In ONLINE mode, the InAppFolderSyncObject property produces an error (I think that is what is causing the message to not get filed in the user-selected folder).  The error says....

       System.Runtime.InteropServices.COMException (0xE9340107): This operation only works with a replicated folder.
       at Microsoft.Office.Interop.Outlook.MAPIFolder.set_InAppFolderSyncObject(Boolean InAppFolderSyncObject)

    Has anyone any ideas? What can I do?

    Thanks.  --Elena
    Wednesday, August 31, 2011 11:52 PM

Answers

  • On my Exchange setup I'm the master domain admin (and every other type of admin), and I have send as permissions on every mailbox on my server and permissions to log into every mailbox directly. Items still end up in "my" mailbox's Sent Items folder, and not in say the Sales mailbox's Sent Items folder. And that's in cached mode.
     
    The same would apply for any other mailbox on my server such as Webmaster or Support (or my dog's mailbox).
     
    That's why I mentioned a Sent Items folder handler. What that would do is fire whenever an item was sent when the item ended up in Sent Items. It would be completely independent of any Application.ItemSend() handler you might have, and would fire after that event handler.
     
    In VB code you'd declare a Folder object and an Items collection object WithEvents and instantiate the Folder as the Sent Items folder, and the Items collection as the Sent Items.Items:
     
        Public oSentItems As Outlook.Folder
        Public WithEvents colItems As Outlook.Items
     
    When the event handler fires you'd check for the sender and sent on behalf of properties to identify items of interest. Then you can get the Sent Items of the other mailbox using NameSpace.GetSharedDefaultFolder() for that mailbox and move the item from one Sent Items to the other.
     
    That can run the same in both onlnie and cached mode, so you wouldn't need any special casing for either mode or variations of those modes.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "ebaralt" <=?utf-8?B?ZWJhcmFsdA==?=> wrote in message news:bba1bda3-62db-40ef-9bf9-0819f155ace9...

    Ken, do you think I can do what you suggested above?  "Does it work if you leave that property unset and handle ItemAdd() for the Sent Items folder's Items collection and move the item to the desired folder?"   but for the outbox instead?  But, my code runs in the ItemSend event, so the sent item wouldn't be in the outbox yet.  Or?

    Or, I've tried the following:

          If conMode = Outlook.OlExchangeConnectionMode.olOnline Then
            'REM Make a copy of the mail item being sent in the Sent Items folder - we will likely NOT do this - but this is the code that would be needed in order to do it.
            Dim mailItemCopy As otk.MailItem = CType(itemMailItem.Copy(), otk.MailItem)
            mailItemCopy.Move(folderToSaveTo)
            'Need to alter the delivery? date on the MailItemCopy - now it's set to nothing - otherwise, the copy works fine.
     
          End If
    
    

    It actually works, however the resultant message has a different icon that other messages that have been sent.  Is this a bad way to go?


    Ken Slovak MVP - Outlook
    • Marked as answer by ebaralt Thursday, September 8, 2011 3:36 PM
    Friday, September 2, 2011 2:42 PM

All replies

  • Why are you setting InAppFolderSyncObject at all? That's used to add or remove a folder from the default send/receive group.
     
    If for some reason you actually need to set that property do so only after checking that the user is running in cached mode and not online mode. You can check NameSpace.ExchangeConnectionMode to see if the user is in cached mode.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "ebaralt" <=?utf-8?B?ZWJhcmFsdA==?=> wrote in message news:68b17bb1-08fc-4ff3-8cd4-c773986e9f54...

    Hi,  we have an Outlook 2007 VSTO addin.  It has an alternative send button which displays a dialog box with certain folders in which the user can 'file' a copy of the sent message.  It all works very well in CACHED mode.  However, in ONLINE mode which we have in our Citrix environment, if the user is a delegate for another user (sending on behalf of), the copies of the sent messages don't appear anywhere.

    The addin's code sets the  MailItem.SaveSentMessageFolder.InAppFolderSyncObject = True.  Then the code sets the MailItem.SaveSentMessageFolder to the user-selected folder.

    In ONLINE mode, the InAppFolderSyncObject property produces an error (I think that is what is causing the message to not get filed in the user-selected folder).  The error says....

       System.Runtime.InteropServices.COMException (0xE9340107): This operation only works with a replicated folder.
       at Microsoft.Office.Interop.Outlook.MAPIFolder.set_InAppFolderSyncObject(Boolean InAppFolderSyncObject)

    Has anyone any ideas? What can I do?

    Thanks.  --Elena

    Ken Slovak MVP - Outlook
    Thursday, September 1, 2011 2:04 PM
  • Ken, thanks for the reply. 

    So, it's not the setting of that property.  Good to know that I can get rid of that code - I think it came along with a snipet I got off the internet (sorry)

    Then I still have to find out why the saved messages are not getting filed/stored in the appropriate folder in ONLINE mode.

    Basically, in the Application.ItemSend event I'm assigning the user-selected folder to the mail item's SaveSentMessageFolder property.  In cached mode this works fine, and the sent message is being filed properly.  But in ONLINE mode, even though the SaveSentMessageFolder property is successfully assigned (when I see it in debugging), the message does not get saved in the folder.  Also, I am checking that the mail item's "DeleteAfterSubmit" property is set to False.

    Thanks for any further ideas you may have.

    --Elena

    Thursday, September 1, 2011 2:44 PM
  • How are you getting the Folder object you're setting the save folder to?
     
    Does it work if you leave that property unset and handle ItemAdd() for the Sent Items folder's Items collection and move the item to the desired folder?

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "ebaralt" <=?utf-8?B?ZWJhcmFsdA==?=> wrote in message news:a9934353-78ff-4c3b-8ece-553d8406100a...

    Ken, thanks for the reply. 

    So, it's not the setting of that property.  Good to know that I can get rid of that code - I think it came along with a snipet I got off the internet (sorry)

    Then I still have to find out why the saved messages are not getting filed/stored in the appropriate folder in ONLINE mode.

    Basically, in the Application.ItemSend event I'm assigning the user-selected folder to the mail item's SaveSentMessageFolder property.  In cached mode this works fine, and the sent message is being filed properly.  But in ONLINE mode, even though the SaveSentMessageFolder property is successfully assigned (when I see it in debugging), the message does not get saved in the folder.  Also, I am checking that the mail item's "DeleteAfterSubmit" property is set to False.

    Thanks for any further ideas you may have.

    --Elena


    Ken Slovak MVP - Outlook
    Thursday, September 1, 2011 3:04 PM
  • Ken, thanks.  I'm getting the folder object from a custom dialog box that has a treeview in it.  The treeview has the "Sent Items" folder and the "My Folders" folder where we encourage our users to create sub-folders.  The selected treevew node has the EntryID of the folder.  So I have a function that returns the folder with that EntryID.  Then I simply do  mailitem.SaveSentMessageFolder = folder.

    I'm confused about the ItemAdd suggestion.  I'm a bit new to Outlook and Outlook programming.  How would that be?

    Again thanks!  --Elena

    Thursday, September 1, 2011 4:26 PM
  • I have one more bit of information regarding this.  I unloaded my addin as well as Worksite addins from Autonomy, and I'm getting the same result.  Messages that have been sent on behalf of someone else are not being saved/filed at all no matter what folder you select natively - in ONLINE mode.  Cached mode works perfectly.

    In a way this is good news - it's not my addin causing it.

    Thursday, September 1, 2011 7:21 PM
  • Ahhh, the messages ARE being saved - in the delegate's Outbox even if the "On behalf of" person has granted access to the folders as well as outbox.  Then they go no further in native word or with my addin in the mix.
    Thursday, September 1, 2011 8:46 PM
  • I should mention also that the messages are actually being sent by the server (and received by the recipient) even though my outbox has months worth of "sent on behalf of" messages in there.
    Thursday, September 1, 2011 9:26 PM
  • Ken, do you think I can do what you suggested above?  "Does it work if you leave that property unset and handle ItemAdd() for the Sent Items folder's Items collection and move the item to the desired folder?"   but for the outbox instead?  But, my code runs in the ItemSend event, so the sent item wouldn't be in the outbox yet.  Or?

    Or, I've tried the following:

          If conMode = Outlook.OlExchangeConnectionMode.olOnline Then
            'REM Make a copy of the mail item being sent in the Sent Items folder - we will likely NOT do this - but this is the code that would be needed in order to do it.
            Dim mailItemCopy As otk.MailItem = CType(itemMailItem.Copy(), otk.MailItem)
            mailItemCopy.Move(folderToSaveTo)
            'Need to alter the delivery? date on the MailItemCopy - now it's set to nothing - otherwise, the copy works fine.
     
          End If
    
    

    It actually works, however the resultant message has a different icon that other messages that have been sent.  Is this a bad way to go?

    Thursday, September 1, 2011 10:27 PM
  • Sorry I didn't get back on this yesterday, I was ill during the afternoon.
     
    You mention "send on behalf of" permissions, what about "send as"?

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "ebaralt" <=?utf-8?B?ZWJhcmFsdA==?=> wrote in message news:4f46adfb-44dc-41a0-b4f5-ba0abd7d73ef...
    I should mention also that the messages are actually being sent by the server (and received by the recipient) even though my outbox has months worth of "sent on behalf of" messages in there.

    Ken Slovak MVP - Outlook
    Friday, September 2, 2011 2:42 PM
  • On my Exchange setup I'm the master domain admin (and every other type of admin), and I have send as permissions on every mailbox on my server and permissions to log into every mailbox directly. Items still end up in "my" mailbox's Sent Items folder, and not in say the Sales mailbox's Sent Items folder. And that's in cached mode.
     
    The same would apply for any other mailbox on my server such as Webmaster or Support (or my dog's mailbox).
     
    That's why I mentioned a Sent Items folder handler. What that would do is fire whenever an item was sent when the item ended up in Sent Items. It would be completely independent of any Application.ItemSend() handler you might have, and would fire after that event handler.
     
    In VB code you'd declare a Folder object and an Items collection object WithEvents and instantiate the Folder as the Sent Items folder, and the Items collection as the Sent Items.Items:
     
        Public oSentItems As Outlook.Folder
        Public WithEvents colItems As Outlook.Items
     
    When the event handler fires you'd check for the sender and sent on behalf of properties to identify items of interest. Then you can get the Sent Items of the other mailbox using NameSpace.GetSharedDefaultFolder() for that mailbox and move the item from one Sent Items to the other.
     
    That can run the same in both onlnie and cached mode, so you wouldn't need any special casing for either mode or variations of those modes.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "ebaralt" <=?utf-8?B?ZWJhcmFsdA==?=> wrote in message news:bba1bda3-62db-40ef-9bf9-0819f155ace9...

    Ken, do you think I can do what you suggested above?  "Does it work if you leave that property unset and handle ItemAdd() for the Sent Items folder's Items collection and move the item to the desired folder?"   but for the outbox instead?  But, my code runs in the ItemSend event, so the sent item wouldn't be in the outbox yet.  Or?

    Or, I've tried the following:

          If conMode = Outlook.OlExchangeConnectionMode.olOnline Then
            'REM Make a copy of the mail item being sent in the Sent Items folder - we will likely NOT do this - but this is the code that would be needed in order to do it.
            Dim mailItemCopy As otk.MailItem = CType(itemMailItem.Copy(), otk.MailItem)
            mailItemCopy.Move(folderToSaveTo)
            'Need to alter the delivery? date on the MailItemCopy - now it's set to nothing - otherwise, the copy works fine.
     
          End If
    
    

    It actually works, however the resultant message has a different icon that other messages that have been sent.  Is this a bad way to go?


    Ken Slovak MVP - Outlook
    • Marked as answer by ebaralt Thursday, September 8, 2011 3:36 PM
    Friday, September 2, 2011 2:42 PM
  • Ken,

    Sorry it's taken me so long to respond.  Your experience is so different from mine.  In ONLINE mode, if I send a message on someone else's behalf, it gets sent, but the sent message only gets filed to the my Outbox (as delegate), not to the indicated folder or the Sent Items folder.  It then remains indefinately in the Outbox.  It can be moved manually...  I wonder if the difference in experiences can be attributed to how Exchange is configured...??

    Anyway, I understand your suggestion of putting a handler on the folder in which the sent messages are landing, and either moving or copying the messages to the user-indicated folder.  I may go this route if management approves.

    Thanks so much.  I have marked your suggestion as ANSWER.

    Again, thanks.  --Elena

    Thursday, September 8, 2011 3:42 PM
  • Part of that may be related to whether or not the sender has "send as" permissions instead of or in addition to "send on behalf of" permissions. In my case, whether in online mode or cached mode, when I send mail as another user it goes to the Sent Items folder of my own mailbox, where I can pick it up and move it to Sent Items in the relevant mailbox.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "ebaralt" <=?utf-8?B?ZWJhcmFsdA==?=> wrote in message news:633ae2ea-ef32-4aa6-9cea-dd35059db8d2...

    Ken,

    Sorry it's taken me so long to respond.  Your experience is so different from mine.  In ONLINE mode, if I send a message on someone else's behalf, it gets sent, but the sent message only gets filed to the my Outbox (as delegate), not to the indicated folder or the Sent Items folder.  It then remains indefinately in the Outbox.  It can be moved manually...  I wonder if the difference in experiences can be attributed to how Exchange is configured...??

    Anyway, I understand your suggestion of putting a handler on the folder in which the sent messages are landing, and either moving or copying the messages to the user-indicated folder.  I may go this route if management approves.

    Thanks so much.  I have marked your suggestion as ANSWER.

    Again, thanks.  --Elena


    Ken Slovak MVP - Outlook
    Thursday, September 8, 2011 6:22 PM