Get list messages
Scenario
Get a list of emails for a user in Microsoft Graph using a GET REST function and displaying the emails in a list jig. Press on an email to view the content of the email.
Resource links:
List messages - MS Graph documentation
Required OAuth scope (least to most privilege):
Mail.ReadBasic Mail.ReadWrite Mail.Read

Examples and code snippets
When using the code and samples in this topic, remember that they are designed to function as part of a comprehensive solution. To fully benefit from the intended functionality and ensure compatibility, it is recommended that you use the entire solution rather than selecting individual components in isolation. Alternatively, you can use these samples as a guide to understand the underlying concepts and MS Graph API, which can help you integrate similar solutions into your projects more effectively. The entire MS Graph solution is available on GitHub.
General
name: ms-graph-demonstrator
title: MS Graph Demonstrator
description: A sample solution that uses the Microsoft Graph API. You can deploy and use this solution without any additional configuration.
category: business
tabs:
home:
jigId: view-user-jigx
icon: home-apps-logo
calendar: "2x2"
jigId: calendar-summary
icon: calendar
meeting:
jigId: next-meeting
when: |
[email protected]=null? false:true
icon: meeting-remote
emails:
jigId: list-email-messages
icon: emailFunctions
MS Graph list messages function in GitHub.
provider: DATA_PROVIDER_REST
method: GET
url: https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages
outputTransform: $
useLocalCall: true
parameters:
accessToken:
location: header
required: true
type: string
value: microsoft.OAuth #Use manage.jigx.com to define credentials for your solution
$filter:
type: string
location: query
required: false
$top:
type: string
location: query
required: false
value: 200
records: =$.value
continuation:
when: =$."@odata.nextLink"
url: =$."@odata.nextLink"
parameters:
accessToken:
location: header
required: true
type: string
value: microsoft.OAuthJigs
MS Graph messages jig in GitHub.
title: ="Inbox - " & $count(@ctx.datasources.mydata) & " items"
type: jig.list
icon: contact
header:
type: component.jig-header
options:
height: small
children:
type: component.image
options:
source:
uri: https://blog.smu.edu/itconnect/files/2020/12/Featured-Image-Email-354CA1-1.png
onRefresh:
type: action.action-list
options:
actions:
- type: action.sync-entities
options:
provider: DATA_PROVIDER_REST
entities:
- entity: email-messages
function: get-email-messages
parameters:
accessToken: microsoft.OAuth
$filter: ="receivedDateTime ge " & $fromMillis($millis()-432000000)
$top: "200"
datasources:
mydata:
type: datasource.sqlite
options:
provider: DATA_PROVIDER_LOCAL
entities:
- entity: email-messages
jsonProperties:
- body
- sender
- from
- toRecipients
- replyTo
query: SELECT id,
'$.receivedDateTime',
'$.sentDateTime',
'$.hasAttachments',
'$.subject',
'$.bodyPreview',
'$.importance',
'$.conversationId',
'$.isRead',
'$.inferenceClassification',
'$.body',
'$.sender',
'$.from',
'$.toRecipients',
'$.ccRecipients',
'$.bccRecipients',
'$.replyTo'
FROM [email-messages]
Where '$.inferenceClassification' LIKE @filter
and json_extract(Data, '$.sender.emailAddress.address') != @me
order by '$.receivedDateTime' desc
queryParameters:
filter: [email protected]
me: [email protected]
data: [email protected]
item:
type: component.list-item
options:
title: [email protected]
divider: solid
subtitle: [email protected]
description: [email protected]
rightElement:
element: icon
icon: =(@ctx.current.item.hasAttachments = 1 ? 'document' :'')
leftElement:
element: avatar
text: =$substring(@ctx.current.item.from.emailAddress.name, 0, 1)
uri: ""
onPress:
type: action.go-to
options:
linkTo: view-email
parameters:
receivedDateTime: [email protected]
sentDateTime: [email protected]
hasAttachments: [email protected]
subject: [email protected]
bodyPreview: [email protected]
importance: [email protected]
conversationId: [email protected]
isRead: [email protected]
inferenceClassification: [email protected]
body: [email protected]
sender: [email protected]
from: [email protected]
toRecipients: [email protected]
ccRecipients: [email protected]
bccRecipients: [email protected]
replyTo: [email protected]
filter:
- title: Focused
value: focused
- title: Other
value: othertitle: [email protected]
type: jig.default
header:
type: component.jig-header
options:
height: small
children:
type: component.image
options:
source:
uri: https://blog.smu.edu/itconnect/files/2020/12/Featured-Image-Email-354CA1-1.png
children:
- type: component.entity
options:
children:
- type: component.field-row
options:
children:
- type: component.entity-field
options:
label: From
value: [email protected]
- type: component.entity-field
options:
label: Recieved
value: =$fromMillis($toMillis(@ctx.jig.inputs.receivedDateTime), '[h]:[m01] [PN]', @ctx.system.timezone.offset)
- type: component.entity-field
options:
label: To
value: [email protected]
- type: component.web-view
options:
height: 800
isTrackingTransparencyRequired: false
content: |
=("
<html>
<head>
<style>
body {
font-family: Arial;
}
</style>
<meta name=" & "'" & "viewport" & "'" & " content=" & "'" & "width=device-width, " & "initial-scale=1" & "'" & "/>
</head>
<body>"
& @ctx.jig.inputs.body.content
& "</body>
</html>")Last updated
Was this helpful?