2

Following on from this thread, I am encountering failures for the first attempt to call SaveAs on an RDOMail object, after using the suggested method in the linked answer to get the server's Message-ID header. I want to get the server message-id because it is the canonical ID (and primary key) for messages for my purposes.

The first attempt to SaveAs using method 1024 gives me a Error in IMessage.GetAttachmentTable: MAPI_E_NOT_FOUND, but if I reattempt the save (that is, run all the code in the saving method again), it succeeds with the save and I can see that it has successfully retrieved the server message-id.

I have tried using 1030 and 1031 for SaveAs and these behave the same (fail first time, then succeed), with 1030 returning a slightly different error: IConverterSession.MAPIToMIMEStm: MAPI_E_NOT_FOUND (1031 returns same error as 1024).

I have a global field in ThisAddin for the Redemption session:

Public Shared rSession As Object

And I assign it in ThisAddin.Startup using RedemptionLoader:

rSession = Redemption.RedemptionLoader.new_RDOSession
rSession.MAPIOBJECT = Globals.ThisAddIn.Application.Session.MAPIOBJECT

Then in my class that manages the saving of emails, I use the suggested method like this:

Dim rdoMailItem As Object
Dim MAPI_NO_CACHE = &H209
Dim MAPI_BEST_ACCESS = &H10
Try
    rdoMailItem = ThisAddIn.rSession.GetMessageFromID(someEntryId, , MAPI_BEST_ACCESS + MAPI_NO_CACHE)
    Dim dummyString = rdoMailItem.Fields("http://schemas.microsoft.com/mapi/proptag/0x1035001F")
    rdoMailItem.SaveAs(someFilePath, 1024)
Catch ex as Exception
    Debug.Print(ex.Message)
End Try

If I omit the further arguments from the GetMessageFromID method, and don't try to get the property using .Fields(...), I don't get the errors and SaveAs works first time (but of course, that doesn't give me the server message-id). So this behaviour appears to arise from the special options and field retrieval.

This is using Redemption version 5.15.0.4892; same behaviour for 5.11.0.4476 which I had handy. Outlook 2010, connected to an Office365 exchange account.

sasfrog
  • 2,410
  • 1
  • 17
  • 28

0 Answers0