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

Free Support Forum - aspose.com

Global XMailer Property

No idea if you have some Global properties to set at main form’s initialize to globally apply some settings to all Aspose functions, but adding a Global.XMailer property would be great, so all message objects by default will have it when saving messages!

For example, when saving Olm/Ost/Pst messages:

InputStorage.ExtractMapiMessage(MyMSG).Save(“D:\Blah.eml”, AsposeSaveOptionsEML)

This global XMailer property will be applied.

If there’s already another approach for this task, please let me know how to apply my default XMailer property when saving from storages as mentioned above?


Aspose.Email does not set such global properties. However, all APIs have default values. You can write your own class that set the default values of SaveOptions according to your requirement and use them when saving messages.

I’m asking that because sometimes we will save email messages without creating any kind of email message object instance, ie:
When reading Pst/Olm/Mboxrd/Tgz…

This allows me direct saving to disk, now how to add XMailer (always or if XMailer is absent from message)

Perhaps save to stream, modify XMailer and then save to disk, imagine a heavy 20GB storage file and this extra mid-stage processing.

Or if there’s already a way or workaround for this, please let me know? :slight_smile:


Please read the following article about setting XMailer property. Hope this helps you.
Set Email Headers

We have logged a ticket for your requirement as EMAILNET-40819. We will inform you once there is an update available on it.

1 Like

Hi, thanks for the link, not my case, to save the time, I clearly describe my 2 requirements:

Case 1. Add my custom XMailer property to all emails ONLY in case if the message does NOT have the XMailer property.

Case 2. Add my custom XMailer property to all emails regardless of whether the message has or hasn’t the XMailer property set.

  • And the question would be that in which cases, Aspose will add it’s name to the XMailer property as the default?


We have logged the shared detail in our issue tracking system. You will be informed once there is an update available on it.


There is no need to save to stream, modify XMailer and then save to disk. You can set the XMailer header value as follows:

var mailerHeader = "X-Mailer";

foreach (MapiMessage mapiMessage in inbox.EnumerateMapiMessages())
    if (mapiMessage.Headers.Contains(mailerHeader))
        mapiMessage.Headers[mailerHeader] = "MyCustomHeader";
        mapiMessage.Headers.Add(mailerHeader, "MyAnotherCustomHeader");

    mapiMessage.Save(emlFileName + ".eml", SaveOptions.DefaultEml);

Aspose doesn’t add its name to XMailer header.