Loading MapiMessage from Stream Does Not Work

Hello,

we nees to save msg files from Office 365 to a PST archive.

But we want to do that using streams (saving msg file to disk previously, it works):

This works:

service.SaveMessage(msgUri, “C:\tempMsg.msg");
MapiMessage msg = MapiMessage.FromMailMessage(“C:\tempMsg.msg");

This doesn’t work:

service.SaveMessage(msgUri, memStream);
MapiMessage msg = MapiMessage.FromStream(memStream);

How to work with streams instead of temporary files?

@albertose,
Thank you for posting the query. Unfortunately, I was unable to reproduce the problem. MapiMessage.FromStream method works fine on my side. You should isolate the problem in your service.SaveMessage method or share some additional data to help us to reproduce the problem.

Can it be caused by the fact I was using the 20.12 version?
Regarding this, I tried to update to the latest version, but unfortunately this caused another issue:
The method:
EWSClient.GetEWSClient(svcUrl, username, password);
Doesn’t work anymore. The program crashes when called. How is it possible?

The exception raised by “EWSClient.GetEWSClient(svcUrl, username, password);” with the latest version is:

Mailbox information can not be read.
Folder Id: ‘msgfolderroot’; Message: Mailbox does not exist.
Folder Id: ‘calendar’; Message: Mailbox does not exist.
Folder Id: ‘contacts’; Message: Mailbox does not exist.
Folder Id: ‘deleteditems’; Message: Mailbox does not exist.
Folder Id: ‘drafts’; Message: Mailbox does not exist.
Folder Id: ‘inbox’; Message: Mailbox does not exist.
Folder Id: ‘journal’; Message: Mailbox does not exist.
Folder Id: ‘notes’; Message: Mailbox does not exist.
Folder Id: ‘outbox’; Message: Mailbox does not exist.
Folder Id: ‘sentitems’; Message: Mailbox does not exist.
Folder Id: ‘tasks’; Message: Mailbox does not exist.
Folder Id: ‘junkemail’; Message: Mailbox does not exist.

If I revert to the previous version, the 20.12, without changing anything in the code, it works.

@albertose,
Thank you for the additional information.

Please share the following:

  • comprehensive code example (msgUri and memStream variables are unknown)
  • stack trace of the error or description of the problem

Unfortunately, we recently found some problems with Aspose.Email 21.8 related to getting mailbox information. This version is not desirable for use. Our development team is preparing a new release. We apologize for any inconvenience. Please use version 21.7.

Ok, we reverted back to the version 21.7 and it works.

Regarding the issue with stream, here is a more complete code:

//***********************************
//Loop through the collection to get Message URI
foreach (string msgUri in mapiMessageList)
{
using (MemoryStream memStream = new MemoryStream())
{

	service.SaveMessage(msgUri, memStream); 

	MapiMessage msg = MapiMessage.FromStream(memStream);  

}

}
//***********************************

SaveMessage method works, saving the message into the memorystream from its URI
When we try to read back from the stream into the variable MapiMessage, the exception is:

ErrorMessage: This is not a structured storage file.
ErrorCode: -2146233079
HexErrorCode:0x80131509

@albertose,
Thank you for the additional information. I reproduced the problem with loading messages from memory streams and logged the issue with ID EMAILNET-40397 in our tracking system. Our development team will investigate this case. You will be notified when the problem is fixed.

Hi, thank you for the information.

Do you think the fix will require many days?

Where can I see the issue resolution progress?

@albertose,
The issue investigation has been scheduled for this week. According to preliminary estimates, the fix will be included in Aspose.Email 21.9 (towards the end of September).

You can see the issue status at the bottom of this forum thread.

Any news regarding the issue?

@albertose,
Our developers are still working on the issue. Unfortunately, I have no news yet.

@albertose,
The problem will be fixed in Aspose.Email 21.9. Also, the MapiMessage.FromStream method will be obsolete but it will work. Starting version 21.9, we will add a new MapiMessage.Load method.

I see the issue has bee resolved, great!

Is the new version already available by NuGet?
Or when it will be ready?

Thank you

@albertose,
Aspose.Email 21.9 will be released towards the end of September.

The issues you have found earlier (filed as EMAILNET-40397) have been fixed in this update.