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

Free Support Forum - aspose.com

Create an empty mapi attachment or recipeint

I’m working in a situation where I have a stream of MAPI properties coming in for messages and their attachments and recipients, and want to recreate the original messages with full fidelity. Aspose seems to have rich support for all mapi properties so that seems very realistic.

However, one peculiarity I found is that I can’t create an “empty” recipient or attachment on a Mapi message.

I want to do the following:

var attachment=new MapiAttachment();
...set properties onto attachment...
message.Attachments.Add(attachment);

But I’m unable to create a new MapiAttachment object. Instead I have to create an attachment with:

msg.Attachments.Add("dummy name", new byte[0]);
var attachment=msg.Attachments.First();

And that risks some characteristics of the dummy one leaking into the message I’m trying to recreate. The same is true of msg.Recipients.

Is there a way around this?

@RobertHunt

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input email file.
  • Please attach the output file that shows the undesired behavior.
  • Please attach the expected output file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

No. I don’t have input email, and the problem is essentially that new MapiAttachment(); gives a compilation error, so I can’t attach an application without compilation errors that demonstrates the problem.

@RobertHunt

We are working over your query and will get back to you soon.

@RobertHunt

Please note that MapiAttachment class does not has constructor.

Please sue this code example to achieve your requirement. You can use MapiAttachment.BinaryData property to set the binary attachment data.

Thanks, I think you’re basically saying that it’s not possible to have an ‘empty’ attachment or recipient, we have to ‘fake’ a dummy one then change its properties - that’s fine if it’s the only way to do it.

Thanks for your help,
Robert