MessageType Class
The MessageType class represents an Exchange e-mail message in a mailbox.
Inheritance Hierarchy
System.Object
ExchangeWebServices.ItemType
ExchangeWebServices.MessageType
ExchangeWebServices.MeetingMessageType
ExchangeWebServices.ResponseObjectCoreType
Namespace: ExchangeWebServices
Assembly: EWS (in EWS.dll)
Syntax
'Declaration
<SerializableAttribute> _
Public Class MessageType _
Inherits ItemType
'Usage
Dim instance As MessageType
[SerializableAttribute]
public class MessageType : ItemType
Remarks
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.
Examples
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 = "user1@example.com";
message.ToRecipients[1] = new EmailAddressType();
message.ToRecipients[1].EmailAddress = "user2@example.com";
message.CcRecipients = new EmailAddressType[1];
message.CcRecipients[0] = new EmailAddressType();
message.CcRecipients[0].EmailAddress = "user3@example.com";
message.BccRecipients = new EmailAddressType[1];
message.BccRecipients[0] = new EmailAddressType();
message.BccRecipients[0].EmailAddress = "user4@example.com";
// 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. </li>" +
"<li>Hiring updates. </li>" +
"<li>Design plan for new facilities.</li>" +
"<li>Identify new opportunities for operational efficiency. </li>" +
"</ul><p>Please provide feedback before the meeting. </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;
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also