We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Performance of Adding Recipients

I’m having problems when creating an MSG file with large numbers of recipients. I’ve created a test file and attached it which will demonstrate the timing curve.

I can create a MSG file with about 2500 recipients and set about 36 Mapi properties per recipient in under a minute. When I get to 5400 recipients it takes about 15 minutes. When I get to 9000 it takes about an hour to build the MSG file.

I have a customer with > 10000 recipients and I can’t have them wait an hour to generate a single MSG file. I’m hoping you can look into this performance issue and offer some suggestions to enhancing the performance.


Hi Christopher,

Thank you for writing to Aspose Support team.

Could you please share the com.google.gson.Gson jar file with us for our further consideration? We need it for our further investigation into this issue and provide assistance in this regard.

You should be able to download the library here: http://central.maven.org/maven2/com/google/code/gson/gson/2.4/gson-2.4.jar


Hi Christopher,

Thank you for sharing the link.

We tried to execute the code, but it raises NullReferenceException as shown in the following:

Exception in thread “main” java.lang.NullPointerException
at MsgTestRecipients.setAllRecipients(MsgTestRecipients.java:105)
at MsgTestRecipients.test(MsgTestRecipients.java:84)
at MsgTestRecipients.main(MsgTestRecipients.java:44)

Could you please share if it needs some other input file as well? I am using the latest version of the API for testing the issue.

Can you re-try this version please?

Hi Christopher,

We are currently investigating this issue at our end and will soon update you here with our findings. We appreciate your patience and cooperation in this regard.

Hi Christopher,

Please update your setAllRecipients method as follow to improve the performance and let us know your feedback.

Sample Code:

private void setAllRecipients(ActRecipient[] recipients, MapiMessage copy) {
int i = 0;
MapiRecipientCollection rc = new MapiRecipientCollection();
for(ActRecipient recipient : recipients) {
rc.add(recipient.getEmailAddress(), recipient.getDisplayName(), recipient.getRecipientType());
MapiRecipient recip = rc.get_Item(i++);

for(ActMapiProp prop : recipient.getProperties()) {
Long tag = prop.getTag();
String hex = prop.getData();
MapiProperty newProp = new MapiProperty(tag, DatatypeConverter.parseHexBinary(hex));
try {
} catch (InvalidOperationException ioe) {
//Nothing to do, skip property

Thank you. That seems to work. I can now process 10,000 recipients in under 5 seconds.

Can I ask why this is such a huge difference?


Thank you for sharing your feedback. This is due to the current implementation of the Mapi Structure in the API that we have plans to improve in future. For the time being, please use the suggested technique for effective performance.