This documentation is archived and is not being maintained.

MessageType Class

The MessageType class represents an Exchange e-mail message in a mailbox.

Namespace:  ExchangeWebServices
Assembly:  EWS (in EWS.dll)

No code example is currently available or this language may not be supported.

The MessageType class has many members that are read-only but that have a setter for the property. This is an artifact from the definition in the schema file. For example, the IsRead property cannot be set when you are creating a message. This property is returned when a message item is received in a response from the computer that is running Microsoft Exchange Server 2007.

You do not have to set the ItemClass property on the MessageType object unless you want to create a custom subtype of IPM.Note. The Exchange server handles the MessageType as an IPM.Note.

MessageType objects represent e-mail messages and all other items that are not strongly typed by the Exchange Web Services (EWS) schema. Items such as IPM.Sharing and IPM.InfoPath are returned as MessageType objects. Microsoft Exchange Server 2010 does not return the base ItemType object in responses.

The following code example shows how to create a message. Note that a message that is returned in a response will have many other properties that are set by the Exchange server.

static MessageType CreateMessage()
    // Create a meesage.
    MessageType message = new MessageType();
    // Add recipients to message.
    message.ToRecipients = new EmailAddressType[2];
    message.ToRecipients[0] = new EmailAddressType();
    message.ToRecipients[0].EmailAddress = "";
    message.ToRecipients[1] = new EmailAddressType();
    message.ToRecipients[1].EmailAddress = "";
    message.CcRecipients = new EmailAddressType[1];
    message.CcRecipients[0] = new EmailAddressType();
    message.CcRecipients[0].EmailAddress = "";
    message.BccRecipients = new EmailAddressType[1];
    message.BccRecipients[0] = new EmailAddressType();
    message.BccRecipients[0].EmailAddress = "";

    // Compose e-mail message.
    message.Subject = "High Priority Projects for Q3";
    message.Body = new BodyType();
    message.Body.BodyType1 = BodyTypeType.HTML;
    message.Body.Value = "<html><body style='font-family: Arial'><ul>" +
     "<li>Create budget for next fiscal year.&nbsp;</li>" + 
     "<li>Hiring updates.&nbsp;</li>" + 
     "<li>Design plan for new facilities.</li>" + 
     "<li>Identify new opportunities for operational efficiency.&nbsp;</li>" +
     "</ul><p>Please provide feedback before the meeting.&nbsp;</p></body></html>";
    message.Sensitivity = SensitivityChoicesType.Confidential;
    message.SensitivitySpecified = true;
    message.Categories = new string[2] { "Planning", "FiscalYear_Next" };
    message.Importance = ImportanceChoicesType.High;
    message.ImportanceSpecified = true;

    return message;

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.