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:

Required OAuth scope (least to most privilege):

Mail.ReadBasic Mail.ReadWrite Mail.Read

Messages
Messages

Examples and code snippets

General

index.jigx
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: email

Functions

MS Graph list messages function in GitHub.

get-email-messages.jigx
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.OAuth

Jigs

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: other

Last updated

Was this helpful?