none
Using MailItem.Save and IMAP resulting in problems RRS feed

  • Question

  • Hello,

    I'm creating a duplicate of an existing mailitem to encrypt the content. During this, I also need to modify the attachments.

    ' Incomplete and reduced snippet
    NewMail = MailObject.Copy ' duplicate original mail
    ' Assign redemption SafeMailItem
    newRDMail = New Redemption.SafeMailItem
    newRDMail.Item = NewMail
    NewMail.Subject = MailObject.Subject & " (converted)"
    NewMail.Save()
    ' ... generate some File ...
    NewMail.Attachments.Add(TempPath & File, Outlook.OlAttachmentType.olByValue, 10)
    NewMail.Save()

    Sadly, I get "The operation cannot be performed because the message has been changed." error message. It looks like Outlook synchronizes the new mail to IMAP folder but I'm not finished. Sometimes, it looks like it synchronizes even without calling the NewMail.Save() function (eg if I need some time to do my stuff). If synchronization runs, I get the error (I believe).

    Is there a reliable way to prevent Outlook from synchronizing before I'm finished? Or is there something I'm doing wrong?

    Thanks!

    Wednesday, October 30, 2013 4:20 PM

Answers

  • Yes, you can save the message as an MSG file and then open it using RDOSession.GetMessageFromMsgFile in Redemption without creating it in any Outlook folder. You can then create a new message in the target folder and import the MSG file using RDOMail.Import(..., olMsg).

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

    • Marked as answer by Schlangengott Tuesday, November 12, 2013 5:03 PM
    Friday, November 8, 2013 2:04 PM

All replies

  • It sounds like the problem is caused when the message is modified by the store provider itself when it downloads the changes from the IMAP server.

    Is this just a temporary message? Does it need to be uploaded to the IMAP server?


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

    Wednesday, October 30, 2013 5:02 PM
  • Hello Dmitry,

    the original MailObject comes from an IMAP folder (ingoing message). My customer has chosen to reconvert this item. So I take this MailObject, create a copy and convert this copy. At the end it should be synchronized. But synchronization seems to happen during my conversion resulting in error. Can I stop this? Or can I do the copy to another location which is not synchronized?

    I found one forum solution where someone said to first save the message as MSG (Redemption) and reload it to get the copy. But where to create the copied item to not have it synchronized? In drafts folder? Can I move this later to the final folder? What is the best way to do so?

    Regards

    Thursday, October 31, 2013 7:06 AM
  • Yes, you can save the message as an MSG file and then open it using RDOSession.GetMessageFromMsgFile in Redemption without creating it in any Outlook folder. You can then create a new message in the target folder and import the MSG file using RDOMail.Import(..., olMsg).

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

    • Marked as answer by Schlangengott Tuesday, November 12, 2013 5:03 PM
    Friday, November 8, 2013 2:04 PM
  • Hi Dmitry,

    this was the missing tip! Thanks!

    Tuesday, November 12, 2013 5:03 PM