Messages
Contains email messages from user mailboxes, including subjects, senders, timestamps, and read status.
Table Specific Information
Select
You can retrieve all from Messages, specify a Message (Id), UserId, or ParentFolderId, or you can filter results by a certain column:
SELECT * FROM Messages WHERE Id = 'MyMessageId' SELECT * FROM Messages WHERE UserId = 'MyUserId' SELECT * FROM Messages WHERE ParentFolderId = 'MyParentfolderId' SELECT * FROM Messages WHERE ParentFolderId = 'Drafts' SELECT DisplayName, Id FROM Users WHERE DisplayName LIKE 'John%'
Insert
After the INSERT, a new Message will be created in the User's Drafts folder.
INSERT INTO Messages (Subject, Body_Content, UserId) VALUES ('New test Email', 'Test Email created.', 'User Id goes here')
Note: To send the mail, see SendMail.
Update
To update a message:
UPDATE Messages SET Subject = 'Email Updated', Body_Content = 'New Body Content' WHERE Id = 'MyMessageId'
Preserving HTML Formatting
If you are executing an INSERT or UPDATE and your message has HTML in its body_content, you must set body_contentType to 'html'.
UPDATE Messages SET body_content = '<my html document>', body_contentType = 'html'
If you don't set body_contentType to 'html', the HTML content of the message (such as elements and tags) will be visible in the body of the resulting email as plaintext instead of being processed as HTML.
Known Issues
This table may return an inconsistent number of results. That is, it can return a number of rows for one query and a different numbers of rows in subsequent queries, even when your messages remain unchanged. This means that some messages may be missing when querying this table.
This is a known bug in the Microsoft Graph API.
There is a workaround that allows the server to retrieve all messages, but it comes with a tradeoff: 'events' and 'contacts' data will be returned along with 'messages' data. When using this workaround, you must use filtering to distinguish between message and non-message rows.
To enable this workaround, add "ClientSidePaging=true;" (without quotation marks) in the value of the Other connection property.
Columns
| Name | Type | ReadOnly | References | Description |
| id [KEY] | String | True |
Unique identifier for the message. | |
| Etag | String | False |
Entity tag representing the version of the message, used for concurrency control. | |
| categories | String | False |
List of categories assigned to the message, such as Red Category or Blue Category. | |
| changeKey | String | False |
Version-specific identifier that changes whenever the message is updated. | |
| createdDateTime | Datetime | False |
Timestamp indicating when the message was created in the mailbox. | |
| lastModifiedDateTime | Datetime | False |
Timestamp of the last modification to the message. | |
| bccRecipients | String | False |
Collection of recipients who received the message as BCC. | |
| body_content | String | False |
HTML or plain text content of the message body. | |
| body_contentType | String | False |
Specifies whether the message body content is in HTML or plain text format. | |
| bodyPreview | String | False |
Text preview of the message body, typically the first few lines. | |
| ccRecipients | String | False |
Collection of recipients who received the message as CC. | |
| conversationId | String | False |
Identifier that groups related messages into the same conversation thread. | |
| conversationIndex | Binary | False |
Binary value used to sort and order messages within the same conversation. | |
| flag_completedDateTime_dateTime | Datetime | False |
Timestamp marking when the follow-up flag was completed. | |
| flag_completedDateTime_timeZone | String | False |
Time zone associated with the flag completion date and time. | |
| flag_flagStatus | String | False |
Status of the follow-up flag, such as notFlagged, complete, or flagged. | |
| from_emailAddress_address | String | False |
Email address of the sender shown in the From field. | |
| from_emailAddress_name | String | False |
Display name of the sender shown in the From field. | |
| hasAttachments | Bool | False |
Indicates whether the message includes one or more file attachments. | |
| importance | String | False |
Priority level of the message: Low, Normal, or High. | |
| inferenceClassification | String | False |
Specifies if the message was classified as focused or other by the inbox rule system. | |
| internetMessageHeaders | String | False |
Raw internet headers of the email message, such as MIME-Version, From, To, and Received. | |
| internetMessageId | String | False |
Globally unique identifier assigned by the sending mail server. | |
| isDeliveryReceiptRequested | Bool | False |
Indicates whether a delivery receipt was requested for the message. | |
| isDraft | Bool | False |
Indicates whether the message has been saved as a draft and not yet sent. | |
| isRead | Bool | False |
Indicates whether the message has been read by the user. | |
| isReadReceiptRequested | Bool | False |
Indicates whether a read receipt was requested for the message. | |
| parentFolderId | String | False |
Identifier of the folder that contains the message. | |
| receivedDateTime | Datetime | False |
Timestamp when the message was received by the mailbox. | |
| replyTo | String | False |
Collection of addresses that replies should be sent to, overriding the From address. | |
| sender_emailAddress_address | String | False |
Email address of the actual sender of the message. | |
| sender_emailAddress_name | String | False |
Display name of the actual sender of the message. | |
| sentDateTime | Datetime | False |
Timestamp when the message was sent. | |
| subject | String | False |
Subject line of the message as entered by the sender. | |
| toRecipients | String | False |
Collection of recipients in the To field of the message. | |
| uniqueBody_content | String | False |
Message body content that excludes previous replies or forwards. | |
| uniqueBody_contentType | String | False |
Specifies the format of the unique body content: HTML or plain text. | |
| webLink | String | False |
URL to open the message directly in Outlook on the web. | |
| UserId | String | False |
Identifier of the user who owns or sent the message. | |
| IsEventMessage | Bool | False |
Indicates whether the message is a calendar invitation or event-related message. |