Getting error while saving MapiMessage to PST file

Getting error “Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.” while saving MAPIMessage object to PST file.

Stack trace
at System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)
at #=zf7UnZPGWxBZojsCzwQuS7Nf0pFD5nD64AA==.#=zSDwUjGwhB$Rd(SortedList`2 #=zLKo880c=)
at #=zf7UnZPGWxBZojsCzwQuS7Nf0pFD5nD64AA==.#=z8FD9m80=(MapiPropertyCollection #=zLKo880c=)
at #=zibxemwRSUDMnD9q9xkeVroLiVzqc$yl$H1gccPIsFnDP.#=zY0QraXx4Q80k(#=zTpXoKjXrefYMHcnsYpoTnFSKX3wemZX8cA== #=zkDpI1LFIsvqu, MapiPropertyCollection #=zLKo880c=)
at #=zibxemwRSUDMnD9q9xkeVroLiVzqc$yl$H1gccPIsFnDP.#=zE54Qxlsxy2lL(#=zTpXoKjXrefYMHcnsYpoTnFSKX3wemZX8cA== #=zkTq3HIM=, MapiPropertyCollection #=zLKo880c=)
at #=zvGB6D$m6$2bhApWC4$ryvbWpshFYjAYl$Nm9m6I=.#=zELw$mlA=(#=zTpXoKjXrefYMHcnsYpoTnFSKX3wemZX8cA== #=za$C8lyvVjqu8, MapiMessage #=zTBm4fO8=)
at Aspose.Email.Storage.Pst.FolderInfo.AddMessage(MapiMessage message)

Hello @ksem!

Thank you for using Aspose.Email. Our support team will be happy to help.

To find out the reason for your problem, we need the following information:

  1. the sample code
  2. MSG file, if the problem appears when adding a certain message or PST file, if the problem appears for a certain PST file. We can make the topic private if the information in your files is confidential.

So far right now I am getting this error for every message I am trying to save. I am setting some properties using SetProperty and some using AddNamedPropertyMapping. I can’t share the sample code though. Is there any way I can share serialized object with you?

@ksem,

Could you, please specify which properties you are setting? We don’t need the whole code but a part of it related to Aspose.Email: loading a message, setting its properties and adding it to pst.
Can you save MapiMessage to a file, zip it up and upload it here to the forum?

It will allow us to see your problem and carry out a proper investigation.

Thank you.

This is item. It looks to be corrupted. Please take a look.msgCustom.zip (5.5 KB)

Hello @ksem,

Yes, we confirm that the file is currupted. And it can not be opened in Outlook. I’m sorry to say but we can’t guarantee that a corrupted file will be added to PST properly.

But I have created the same file using the Aspose.Email APIs. What else can I share with you to look deeper into this? All the properties with their tags which I am trying to save?

@ksem,

We need the code sample that you use for creating this file.

I am able to add message to PST file. I was previously converting the object value to byte array thinking it is the only way to set MapiProperty values. But later found out it can accept object values as well with PropertyDescriptor, so it worked. Thanks for your help. You can close this ticket.

@ksem,

We are happy your could make it work. Thanks for writing to Aspose support.