Package com.independentsoft.graph.mails

# Class Message

java.lang.Object
com.independentsoft.graph.mails.Message

All Implemented Interfaces:
  `ICreatable`, `IUpdatable`

Direct Known Subclasses:
  `EventMessage`

public class Message extends Object implements ICreatable, IUpdatable
Represents an email message in a mailbox folder in Microsoft Graph.

The Message resource represents an email message in Microsoft 365. Messages can be drafts or sent items, and can include attachments, recipients, and various metadata. This class provides comprehensive access to all message properties and supports operations like create, read, update, delete, send, forward, and reply.

Common message operations include:

- Creating and sending new messages
- Reading message properties (subject, body, recipients, etc.)
- Managing message attachments (file attachments, item attachments)
- Replying to and forwarding messages
- Moving messages between folders
- Marking messages as read/unread
- Flagging messages for follow-up
- Working with extended properties

Example usage:

     GraphClient client = new GraphClient();
     // ... configure authentication ...

     // Create and send a new message
     Message message = new Message();
     message.setSubject(\"Hello from Graph API\");

     ItemBody body = new ItemBody();
     body.setContentType(BodyType.TEXT);
     body.setContent(\"This is a test message\");
     message.setBody(body);

     EmailAddress to = new EmailAddress();
     to.setAddress(\"user@example.com\");
     message.getToRecipients().add(to);

     client.sendMessage(message);

     // List messages in inbox
     List<Message> messages = client.listMessages();
     for (Message msg : messages) {
         System.out.println(msg.getSubject());
     }

Since:
  1.0
See Also:
  Message resource type, Send message, List messages

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected List<Attachment>`
  `attachments`
  `protected List<EmailAddress>`
  `bccRecipients`
  `protected ItemBody`
  `body`
  `protected String`
  `bodyPreview`
  `protected List<String>`
  `categories`
  `protected List<EmailAddress>`
  `ccRecipients`
  `protected String`
  `changeKey`
  `protected String`
  `conversationId`
  `protected String`
  `conversationIndex`
  `protected Date`
  `createdTime`
  `protected List<ExtendedProperty>`
  `extendedProperties`
  `protected FollowupFlag`
  `flag`
  `protected EmailAddress`
  `from`
  `protected boolean`
  `hasAttachments`
  `protected String`
  `id`
  `protected Importance`
  `importance`
  `protected InferenceClassification`
  `inferenceClassification`
  `protected List<InternetMessageHeader>`
  `internetMessageHeaders`
  `protected String`
  `internetMessageId`
  `protected boolean`
  `isDeliveryReceiptRequested`
  `protected boolean`
  `isDraft`
  `protected boolean`
  `isRead`
  `protected boolean`
  `isReadReceiptRequested`
  `protected Date`
  `lastModifiedTime`
  `protected boolean`
  `mentionsPreview`
  `protected String`
  `parentFolderId`
  `protected Date`
  `receivedTime`
  `protected List<EmailAddress>`
  `replyTo`
  `protected EmailAddress`
  `sender`
  `protected Date`
  `sentTime`
  `protected String`
  `subject`
  `protected List<EmailAddress>`
  `toRecipients`
  `protected ItemBody`
  `uniqueBody`
  `protected String`
  `unsubscribeData`
  `protected boolean`
  `unsubscribeEnabled`
  `protected String`
  `webLink`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Message()`
  `Message​(JsonObject jsonObject)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `List<Attachment>`
  `getAttachments()`
  `List<EmailAddress>`
  `getBccRecipients()`
  `ItemBody`
  `getBody()`
  `String`
  `getBodyPreview()`
  `List<String>`
  `getCategories()`
  `List<EmailAddress>`
  `getCcRecipients()`
  `String`
  `getChangeKey()`
  `String`
  `getConversationId()`
  `String`
  `getConversationIndex()`
  `Date`
  `getCreatedTime()`
  `List<ExtendedProperty>`
  `getExtendedProperties()`
  `FollowupFlag`
  `getFlag()`
  `EmailAddress`
  `getFrom()`
  `String`
  `getId()`
  `Importance`
  `getImportance()`
  `InferenceClassification`
  `getInferenceClassification()`
  `List<InternetMessageHeader>`
  `getInternetMessageHeaders()`
  `String`
  `getInternetMessageId()`
  `Date`
  `getLastModifiedTime()`
  `String`
  `getParentFolderId()`
  `Date`
  `getReceivedTime()`
  `List<EmailAddress>`
  `getReplyTo()`
  `EmailAddress`
  `getSender()`
  `Date`
  `getSentTime()`
  `String`
  `getSubject()`
  `List<EmailAddress>`
  `getToRecipients()`
  `ItemBody`
  `getUniqueBody()`
  `String`
  `getUnsubscribeData()`
  `String`
  `getWebLink()`
  `boolean`
  `hasAttachments()`
  `boolean`
  `isDeliveryReceiptRequested()`
  `boolean`
  `isDraft()`
  `boolean`
  `isRead()`
  `boolean`
  `isReadReceiptRequested()`
  `boolean`
  `mentionsPreview()`
  `void`
  `setAsDeliveryReceiptRequested​(boolean isDeliveryReceiptRequested)`
  `void`
  `setAsDraft​(boolean isDraft)`
  `void`
  `setAsRead​(boolean isRead)`
  `void`
  `setAsReadReceiptRequested​(boolean isReadReceiptRequested)`
  `void`
  `setBody​(ItemBody body)`
  `void`
  `setFlag​(FollowupFlag flag)`
  `void`
  `setFrom​(EmailAddress from)`
  `void`
  `setHasAttachments​(boolean hasAttachments)`
  `void`
  `setId​(String id)`
  `void`
  `setImportance​(Importance importance)`
  `void`
  `setInferenceClassification​(InferenceClassification inferenceClassification)`
  `void`
  `setInternetMessageId​(String internetMessageId)`
  `void`
  `setSender​(EmailAddress sender)`
  `void`
  `setSubject​(String subject)`
  `void`
  `setUnsubscribeData​(String unsubscribeData)`
  `void`
  `setUnsubscribeEnabled​(boolean unsubscribeEnabled)`
  `String`
  `toAttachmentItem()`
  `String`
  `toCreateJson()`
  Converts this object to its JSON representation for creation.
  `String`
  `toString()`
  `String`
  `toUpdateJson()`
  Converts this object to its JSON representation for update.
  `String`
  `toUpdateJson​(List<String> propertyNames)`
  Converts this object to JSON for update with specific properties.
  `boolean`
  `unsubscribeEnabled()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### id

    protected String id

  - ### changeKey

    protected String changeKey

  - ### bccRecipients

    protected List<EmailAddress> bccRecipients

  - ### body

    protected ItemBody body

  - ### bodyPreview

    protected String bodyPreview

  - ### categories

    protected List<String> categories

  - ### ccRecipients

    protected List<EmailAddress> ccRecipients

  - ### conversationId

    protected String conversationId

  - ### conversationIndex

    protected String conversationIndex

  - ### createdTime

    protected Date createdTime

  - ### flag

    protected FollowupFlag flag

  - ### from

    protected EmailAddress from

  - ### hasAttachments

    protected boolean hasAttachments

  - ### importance

    protected Importance importance

  - ### inferenceClassification

    protected InferenceClassification inferenceClassification

  - ### internetMessageHeaders

    protected List<InternetMessageHeader> internetMessageHeaders

  - ### internetMessageId

    protected String internetMessageId

  - ### isDeliveryReceiptRequested

    protected boolean isDeliveryReceiptRequested

  - ### isDraft

    protected boolean isDraft

  - ### isRead

    protected boolean isRead

  - ### isReadReceiptRequested

    protected boolean isReadReceiptRequested

  - ### lastModifiedTime

    protected Date lastModifiedTime

  - ### mentionsPreview

    protected boolean mentionsPreview

  - ### parentFolderId

    protected String parentFolderId

  - ### receivedTime

    protected Date receivedTime

  - ### replyTo

    protected List<EmailAddress> replyTo

  - ### sender

    protected EmailAddress sender

  - ### sentTime

    protected Date sentTime

  - ### subject

    protected String subject

  - ### toRecipients

    protected List<EmailAddress> toRecipients

  - ### uniqueBody

    protected ItemBody uniqueBody

  - ### unsubscribeData

    protected String unsubscribeData

  - ### unsubscribeEnabled

    protected boolean unsubscribeEnabled

  - ### webLink

    protected String webLink

  - ### extendedProperties

    protected List<ExtendedProperty> extendedProperties

  - ### attachments

    protected List<Attachment> attachments

- ## Constructor Details

  - ### Message

    public Message()

  - ### Message

    public Message​(JsonObject jsonObject)

- ## Method Details

  - ### toAttachmentItem

    public String toAttachmentItem()

  - ### toCreateJson

    public String toCreateJson()
    Description copied from interface: `ICreatable`
    Converts this object to its JSON representation for creation.

    This method generates a JSON string containing all properties needed to create a new instance of this resource in Microsoft Graph. Only properties appropriate for creation should be included (e.g., excluding read-only properties like ID, createdTime, etc.).

    Specified by:
      `toCreateJson` in interface `ICreatable`
    Returns:
      JSON string representation for creating this resource

  - ### toUpdateJson

    public String toUpdateJson()
    Description copied from interface: `IUpdatable`
    Converts this object to its JSON representation for update.

    This method generates a JSON string containing all modified properties that should be updated in Microsoft Graph. Only writeable properties with non-null values are typically included.

    Specified by:
      `toUpdateJson` in interface `IUpdatable`
    Returns:
      JSON string representation for updating this resource

  - ### toUpdateJson

    public String toUpdateJson​(List<String> propertyNames)
    Description copied from interface: `IUpdatable`
    Converts this object to JSON for update with specific properties.

    This method generates a JSON string containing only the specified properties. This enables partial updates where only certain fields need to be modified, reducing payload size and avoiding unintended changes to other properties.

    Specified by:
      `toUpdateJson` in interface `IUpdatable`
    Parameters:
      `propertyNames` - List of property names to include in the JSON. If null or empty, all modified properties are included.
    Returns:
      JSON string representation for updating specific properties

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getId

    public String getId()

  - ### setId

    public void setId​(String id)

  - ### getChangeKey

    public String getChangeKey()

  - ### getBccRecipients

    public List<EmailAddress> getBccRecipients()

  - ### getBody

    public ItemBody getBody()

  - ### setBody

    public void setBody​(ItemBody body)

  - ### getBodyPreview

    public String getBodyPreview()

  - ### getCategories

    public List<String> getCategories()

  - ### getCcRecipients

    public List<EmailAddress> getCcRecipients()

  - ### getConversationId

    public String getConversationId()

  - ### getConversationIndex

    public String getConversationIndex()

  - ### getCreatedTime

    public Date getCreatedTime()

  - ### getFlag

    public FollowupFlag getFlag()

  - ### setFlag

    public void setFlag​(FollowupFlag flag)

  - ### getFrom

    public EmailAddress getFrom()

  - ### setFrom

    public void setFrom​(EmailAddress from)

  - ### hasAttachments

    public boolean hasAttachments()

  - ### setHasAttachments

    public void setHasAttachments​(boolean hasAttachments)

  - ### getImportance

    public Importance getImportance()

  - ### setImportance

    public void setImportance​(Importance importance)

  - ### getInferenceClassification

    public InferenceClassification getInferenceClassification()

  - ### setInferenceClassification

    public void setInferenceClassification​(InferenceClassification inferenceClassification)

  - ### getInternetMessageHeaders

    public List<InternetMessageHeader> getInternetMessageHeaders()

  - ### getInternetMessageId

    public String getInternetMessageId()

  - ### setInternetMessageId

    public void setInternetMessageId​(String internetMessageId)

  - ### isDeliveryReceiptRequested

    public boolean isDeliveryReceiptRequested()

  - ### setAsDeliveryReceiptRequested

    public void setAsDeliveryReceiptRequested​(boolean isDeliveryReceiptRequested)

  - ### isDraft

    public boolean isDraft()

  - ### setAsDraft

    public void setAsDraft​(boolean isDraft)

  - ### isRead

    public boolean isRead()

  - ### setAsRead

    public void setAsRead​(boolean isRead)

  - ### isReadReceiptRequested

    public boolean isReadReceiptRequested()

  - ### setAsReadReceiptRequested

    public void setAsReadReceiptRequested​(boolean isReadReceiptRequested)

  - ### getLastModifiedTime

    public Date getLastModifiedTime()

  - ### mentionsPreview

    public boolean mentionsPreview()

  - ### getParentFolderId

    public String getParentFolderId()

  - ### getReceivedTime

    public Date getReceivedTime()

  - ### getReplyTo

    public List<EmailAddress> getReplyTo()

  - ### getSender

    public EmailAddress getSender()

  - ### setSender

    public void setSender​(EmailAddress sender)

  - ### getSentTime

    public Date getSentTime()

  - ### getSubject

    public String getSubject()

  - ### setSubject

    public void setSubject​(String subject)

  - ### getToRecipients

    public List<EmailAddress> getToRecipients()

  - ### getUniqueBody

    public ItemBody getUniqueBody()

  - ### getUnsubscribeData

    public String getUnsubscribeData()

  - ### setUnsubscribeData

    public void setUnsubscribeData​(String unsubscribeData)

  - ### unsubscribeEnabled

    public boolean unsubscribeEnabled()

  - ### setUnsubscribeEnabled

    public void setUnsubscribeEnabled​(boolean unsubscribeEnabled)

  - ### getWebLink

    public String getWebLink()

  - ### getExtendedProperties

    public List<ExtendedProperty> getExtendedProperties()

  - ### getAttachments

    public List<Attachment> getAttachments()