Share via


MessageType Class

The MessageType class represents an Exchange e-mail message in a mailbox or a non-IPM.Note item.

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

Syntax

'Declaration
<SerializableAttribute> _
<XmlIncludeAttribute(GetType(MeetingCancellationMessageType))> _
<GeneratedCodeAttribute("wsdl", "2.0.50727.42")> _
<XmlTypeAttribute(Namespace:="https://schemas.microsoft.com/exchange/services/2006/types")> _
<XmlIncludeAttribute(GetType(MeetingMessageType))> _
<XmlIncludeAttribute(GetType(MeetingResponseMessageType))> _
<XmlIncludeAttribute(GetType(MeetingRequestMessageType))> _
<XmlIncludeAttribute(GetType(ResponseObjectCoreType))> _
<XmlIncludeAttribute(GetType(ResponseObjectType))> _
<XmlIncludeAttribute(GetType(PostReplyItemBaseType))> _
<XmlIncludeAttribute(GetType(PostReplyItemType))> _
<XmlIncludeAttribute(GetType(RemoveItemType))> _
<XmlIncludeAttribute(GetType(ReferenceItemResponseType))> _
<XmlIncludeAttribute(GetType(SuppressReadReceiptType))> _
<XmlIncludeAttribute(GetType(SmartResponseBaseType))> _
<XmlIncludeAttribute(GetType(SmartResponseType))> _
<XmlIncludeAttribute(GetType(CancelCalendarItemType))> _
<XmlIncludeAttribute(GetType(ForwardItemType))> _
<XmlIncludeAttribute(GetType(ReplyAllToItemType))> _
<XmlIncludeAttribute(GetType(ReplyToItemType))> _
<XmlIncludeAttribute(GetType(WellKnownResponseObjectType))> _
<XmlIncludeAttribute(GetType(DeclineItemType))> _
<DesignerCategoryAttribute("code")> _
<XmlIncludeAttribute(GetType(AcceptItemType))> _
<XmlIncludeAttribute(GetType(TentativelyAcceptItemType))> _
<DebuggerStepThroughAttribute> _
Public Class MessageType
    Inherits ItemType
[SerializableAttribute] 
[XmlIncludeAttribute(typeof(MeetingCancellationMessageType))] 
[GeneratedCodeAttribute("wsdl", "2.0.50727.42")] 
[XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/types")] 
[XmlIncludeAttribute(typeof(MeetingMessageType))] 
[XmlIncludeAttribute(typeof(MeetingResponseMessageType))] 
[XmlIncludeAttribute(typeof(MeetingRequestMessageType))] 
[XmlIncludeAttribute(typeof(ResponseObjectCoreType))] 
[XmlIncludeAttribute(typeof(ResponseObjectType))] 
[XmlIncludeAttribute(typeof(PostReplyItemBaseType))] 
[XmlIncludeAttribute(typeof(PostReplyItemType))] 
[XmlIncludeAttribute(typeof(RemoveItemType))] 
[XmlIncludeAttribute(typeof(ReferenceItemResponseType))] 
[XmlIncludeAttribute(typeof(SuppressReadReceiptType))] 
[XmlIncludeAttribute(typeof(SmartResponseBaseType))] 
[XmlIncludeAttribute(typeof(SmartResponseType))] 
[XmlIncludeAttribute(typeof(CancelCalendarItemType))] 
[XmlIncludeAttribute(typeof(ForwardItemType))] 
[XmlIncludeAttribute(typeof(ReplyAllToItemType))] 
[XmlIncludeAttribute(typeof(ReplyToItemType))] 
[XmlIncludeAttribute(typeof(WellKnownResponseObjectType))] 
[XmlIncludeAttribute(typeof(DeclineItemType))] 
[DesignerCategoryAttribute("code")] 
[XmlIncludeAttribute(typeof(AcceptItemType))] 
[XmlIncludeAttribute(typeof(TentativelyAcceptItemType))] 
[DebuggerStepThroughAttribute] 
public class MessageType : ItemType
[SerializableAttribute] 
[XmlIncludeAttribute(typeof(MeetingCancellationMessageType))] 
[GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42")] 
[XmlTypeAttribute(Namespace=L"https://schemas.microsoft.com/exchange/services/2006/types")] 
[XmlIncludeAttribute(typeof(MeetingMessageType))] 
[XmlIncludeAttribute(typeof(MeetingResponseMessageType))] 
[XmlIncludeAttribute(typeof(MeetingRequestMessageType))] 
[XmlIncludeAttribute(typeof(ResponseObjectCoreType))] 
[XmlIncludeAttribute(typeof(ResponseObjectType))] 
[XmlIncludeAttribute(typeof(PostReplyItemBaseType))] 
[XmlIncludeAttribute(typeof(PostReplyItemType))] 
[XmlIncludeAttribute(typeof(RemoveItemType))] 
[XmlIncludeAttribute(typeof(ReferenceItemResponseType))] 
[XmlIncludeAttribute(typeof(SuppressReadReceiptType))] 
[XmlIncludeAttribute(typeof(SmartResponseBaseType))] 
[XmlIncludeAttribute(typeof(SmartResponseType))] 
[XmlIncludeAttribute(typeof(CancelCalendarItemType))] 
[XmlIncludeAttribute(typeof(ForwardItemType))] 
[XmlIncludeAttribute(typeof(ReplyAllToItemType))] 
[XmlIncludeAttribute(typeof(ReplyToItemType))] 
[XmlIncludeAttribute(typeof(WellKnownResponseObjectType))] 
[XmlIncludeAttribute(typeof(DeclineItemType))] 
[DesignerCategoryAttribute(L"code")] 
[XmlIncludeAttribute(typeof(AcceptItemType))] 
[XmlIncludeAttribute(typeof(TentativelyAcceptItemType))] 
[DebuggerStepThroughAttribute] 
public ref class MessageType : public ItemType
/** @attribute SerializableAttribute() */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.MeetingCancellationMessageType) */ 
/** @attribute GeneratedCodeAttribute("wsdl", "2.0.50727.42") */ 
/** @attribute XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/types") */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.MeetingMessageType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.MeetingResponseMessageType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.MeetingRequestMessageType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.ResponseObjectCoreType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.ResponseObjectType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.PostReplyItemBaseType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.PostReplyItemType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.RemoveItemType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.ReferenceItemResponseType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.SuppressReadReceiptType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.SmartResponseBaseType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.SmartResponseType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.CancelCalendarItemType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.ForwardItemType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.ReplyAllToItemType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.ReplyToItemType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.WellKnownResponseObjectType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.DeclineItemType) */ 
/** @attribute DesignerCategoryAttribute("code") */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.AcceptItemType) */ 
/** @attribute XmlIncludeAttribute(ExchangeWebServices.TentativelyAcceptItemType) */ 
/** @attribute DebuggerStepThroughAttribute() */ 
public class MessageType extends ItemType
SerializableAttribute 
XmlIncludeAttribute(ExchangeWebServices.MeetingCancellationMessageType) 
GeneratedCodeAttribute("wsdl", "2.0.50727.42") 
XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/types") 
XmlIncludeAttribute(ExchangeWebServices.MeetingMessageType) 
XmlIncludeAttribute(ExchangeWebServices.MeetingResponseMessageType) 
XmlIncludeAttribute(ExchangeWebServices.MeetingRequestMessageType) 
XmlIncludeAttribute(ExchangeWebServices.ResponseObjectCoreType) 
XmlIncludeAttribute(ExchangeWebServices.ResponseObjectType) 
XmlIncludeAttribute(ExchangeWebServices.PostReplyItemBaseType) 
XmlIncludeAttribute(ExchangeWebServices.PostReplyItemType) 
XmlIncludeAttribute(ExchangeWebServices.RemoveItemType) 
XmlIncludeAttribute(ExchangeWebServices.ReferenceItemResponseType) 
XmlIncludeAttribute(ExchangeWebServices.SuppressReadReceiptType) 
XmlIncludeAttribute(ExchangeWebServices.SmartResponseBaseType) 
XmlIncludeAttribute(ExchangeWebServices.SmartResponseType) 
XmlIncludeAttribute(ExchangeWebServices.CancelCalendarItemType) 
XmlIncludeAttribute(ExchangeWebServices.ForwardItemType) 
XmlIncludeAttribute(ExchangeWebServices.ReplyAllToItemType) 
XmlIncludeAttribute(ExchangeWebServices.ReplyToItemType) 
XmlIncludeAttribute(ExchangeWebServices.WellKnownResponseObjectType) 
XmlIncludeAttribute(ExchangeWebServices.DeclineItemType) 
DesignerCategoryAttribute("code") 
XmlIncludeAttribute(ExchangeWebServices.AcceptItemType) 
XmlIncludeAttribute(ExchangeWebServices.TentativelyAcceptItemType) 
DebuggerStepThroughAttribute 
public class MessageType extends 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.

Starting with Exchange Server 2007 Service Pack 1 (SP1) with Update Rollup 4 (RU4) applied, the MessageType class represents e-mail messages and all other items that are not strongly typed by the Exchange Web Services (EWS) schema. This behavior is applied when the Exchange2007_SP1 version header is specified. Items such as IPM.Sharing and IPM.InfoPath will be returned as MessageType objects. Exchange 2007 SP1 with RU4 applied and later versions will not return the base ItemType type in responses.

Inheritance Hierarchy

System.Object
   ExchangeWebServices.ItemType
    ExchangeWebServices.MessageType
       ExchangeWebServices.MeetingMessageType
       ExchangeWebServices.ResponseObjectCoreType

Example

The following code example shows you 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.&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;
}

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.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003,

Target Platforms

Windows 98, Windows 2000, Windows 2000 Server, Windows CE, Windows Longhorn, Windows 98 Second Edition, Pocket PC, Smart Phone, Windows Server 2003, Windows XP Professional with Service Pack 2 (SP2)