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

Free Support Forum - aspose.com

Adding Extended Attribute to Message

Can we create Extended attribute to a message on Exchange server?

@AaronShameel,

Yes the API supports adding and retrieving Extended Attributes information to message on Exchange server. Please have a look at the following code sample for your kind reference.

Sample Code

NetworkCredential credential = new NetworkCredential(username, password, domain);
IEWSClient client = EWSClient.GetEWSClient(mailboxURI, credential);
{
    try
    {
        //Create a new Property
        PidNamePropertyDescriptor pd = new PidNamePropertyDescriptor(
            "MyTestProp",
            PropertyDataType.String,
            KnownPropertySets.PublicStrings);
        string value = "MyTestPropValue";

        //Create a message
        MapiMessage message = new MapiMessage(
            "from@domain.com",
            "to@domain.com",
            "EMAILNET-38844 - " + Guid.NewGuid().ToString(),
            "EMAILNET-38844 EWS: Support for create, retrieve and update Extended Attributes for Emails");

        //Set property on the message
        message.SetProperty(pd, value);

        //append the message to server
        string uri = client.AppendMessage(message);

        //Fetch the message from server
        MapiMessage mapiMessage = client.FetchMapiMessage(uri, new PropertyDescriptor[] { pd });

        //Retreive the value from Message
        string fetchedValue = mapiMessage.NamedProperties[pd].GetString();
    }
    finally
    {
    }
}