none
Moving an Outlook email from one store to another resulst in lost sent information RRS feed

  • Question

  • Dear all,

    I try to write a function in which an outlook.mailitem is sent. As such, that works fine.

    In Outlook, on top of a persons' email account, an additional mailbox is added. That mailbox can be accessed by multiple colleagues.

    I succeed sending the mail  using the below command:

    oMsg.SentOnBehalfOfName

    Again, that works fine. However, I would like the sent message to be saved in the 'Sent Items' mailbox of the additional mailbox.

    That's where may problem starts. the message is saved in the 'Sent Items' of the persons' email account.

    Changing the below:

    oMsg.SaveSentMessageFolder

    does not work when I choose a folder outside of the primary session.store. I saw threats confirming this is a limitation of the 'SaveSentMessagFolder' command.

    Next I tried is to move the mail to the additional mailbox. Again, that works, but now all the info in the 'Sent ' field is lost. I can no longer see when the mail was sent. Also the 'OnBehalfOf' piece of information is lost.

    • Moved by Youen Zen Thursday, December 13, 2012 6:46 AM Appropriate forum for this issue (From:Visual Basic Interop and Upgrade)
    • Edited by 许阳(无锡)Moderator Thursday, December 13, 2012 6:51 AM format OP's post to let it easy to read
    Wednesday, December 12, 2012 10:44 AM

Answers

  • What is your code that moves the message?

    How do you open the target store and folder? 


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    • Marked as answer by HansLeijs Thursday, December 13, 2012 7:04 PM
    Thursday, December 13, 2012 3:06 PM

All replies

  • Hi Hans,

    We have a forum Outlook for developers forum for this issue. In order to provide better support, I'll move this thread.

    Thanks for understanding.


    Shanks Zen
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 13, 2012 6:45 AM
  • Hi HansLeiis,

    Thanks for posting in the MSDN Forum.

    Do you move the mail from one store to another via program?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 13, 2012 6:49 AM
    Moderator
  • I cannot repro your problem.
     
    If I use code to move an item from the default Sent Items folder to Sent Items in another open store that information remains intact.
     
    I tested by selecting an item in the default Sent Items folder and using the following VBA test code:
     
    Sub MoveToOtherStore()
        Dim s As Outlook.Store
        Dim f As Outlook.Folder
        Dim i As Outlook.MailItem
        Dim i1 As Outlook.MailItem
       
        Set i = Application.ActiveExplorer.Selection.Item(1)
       
        Set s = Application.Session.Stores(2)
        Debug.Print s.DisplayName
       
        Set f = s.GetDefaultFolder(olFolderSentMail)
        Set i1 = i.Move(f)
    End Sub

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "HansLeijs" <=?utf-8?B?SGFuc0xlaWpz?=> wrote in message news:fb652905-de56-49bb-a003-5839267993da...

    Dear all,

    I try to write a function in which an outlook.mailitem is sent. As such, that works fine.

    In Outlook, on top of a persons' email account, an additional mailbox is added. That mailbox can be accessed by multiple colleagues.

    I succeed sending the mail  using the below command:

    oMsg.SentOnBehalfOfName

    Again, that works fine. However, I would like the sent message to be saved in the 'Sent Items' mailbox of the additional mailbox.

    That's where may problem starts. the message is saved in the 'Sent Items' of the persons' email account.

    Changing the below:

    oMsg.SaveSentMessageFolder

    does not work when I choose a folder outside of the primary session.store. I saw threats confirming this is a limitation of the 'SaveSentMessagFolder' command.

    Next I tried is to move the mail to the additional mailbox. Again, that works, but now all the info in the 'Sent ' field is lost. I can no longer see when the mail was sent. Also the 'OnBehalfOf' piece of information is lost.


    Ken Slovak MVP - Outlook
    Thursday, December 13, 2012 2:48 PM
    Moderator
  • What is your code that moves the message?

    How do you open the target store and folder? 


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    • Marked as answer by HansLeijs Thursday, December 13, 2012 7:04 PM
    Thursday, December 13, 2012 3:06 PM
  • Dear Ken,

    I recognized the item I overlooked.

            oMsg.Save()
            oMsg.Move(oApp.Session.Folders(2).Folders("Test")) 'works, but the sent date/time is lost    
            oMsg.Send()

    I tried to move the message prior to sending. Strangely enough, it works. I now begin to suspect, that what I really move is the message drafted so far. At first I had the oMsg.Move command after the oMsg.Send which didn't work, because the message object apparently is already released.

    Moving the message before the send command cannot have the "Sent" information available. It may never be sent at all.

    Sorry for any confusion and bothering you.

    best regards,

    Hans

    Thursday, December 13, 2012 7:03 PM
  • you have to listen for ItemAdd on SentItems folder and move mail from there to target store/folder. This way it will have all sent* information
    Thursday, December 13, 2012 7:53 PM
  • I had tested on sent items, only they would have actual "send*" information. Any other items are just drafts and have no sent information as they never were sent.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "HansLeijs" <=?utf-8?B?SGFuc0xlaWpz?=> wrote in message news:a76123dc-4a24-457d-a910-cf66165d32a8...

    Dear Ken,

    I recognized the item I overlooked.

            oMsg.Save()
            oMsg.Move(oApp.Session.Folders(2).Folders("Test")) 'works, but the sent date/time is lost    
            oMsg.Send()

    I tried to move the message prior to sending. Strangely enough, it works. I now begin to suspect, that what I really move is the message drafted so far. At first I had the oMsg.Move command after the oMsg.Send which didn't work, because the message object apparently is already released.

    Moving the message before the send command cannot have the "Sent" information available. It may never be sent at all.

    Sorry for any confusion and bothering you.

    best regards,

    Hans


    Ken Slovak MVP - Outlook
    Thursday, December 13, 2012 7:57 PM
    Moderator
  • Move is a function that returns the message. The old message must be immediately released:

    oMsg = oMsg.Move(oApp.Session.Folders(2).Folders("Test"))

    Still, follow Damian's advise and process the message only after it is asynchronously sent.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Thursday, December 13, 2012 8:27 PM
  • Dear Damian,

    I have read this advise at other places as well. However, I have no idea how to do that in my vb.net program.

    Can you please help me?

    best regards,

    Hans

    Thursday, December 13, 2012 10:42 PM
  • pseudocode:

    dim defaultSentItems as Items

    sub addinstartup()

    defaultSentItems = Application.Session.GetDefaultFolder(olSentItems).Items

    AddHanlder MailAddedToDefault AddressOF defaultSentItems.ItemAdd

    end sub

    MailAddedToDefault (item as Object)

     mail = trycast (item, MailItem)

    if this is mailitem, you can now move it to another store/folder

    Friday, December 14, 2012 5:05 AM