使用Microsoft图形更新电子邮件类别

时间:2019-09-20 11:29:36

标签: python html graph outlook azure-ad-graph-api

我正在尝试使用PATCH和Microsoft图形来更新电子邮件的类别。

但是我不确定如何进行

def get_my_messages(access_token):
  get_messages_url = graph_endpoint.format('/me/mailfolders/inbox/messages')

  # Use OData query parameters to control the results
  #  - Only first 10 results returned
  #  - Only return the ReceivedDateTime, Subject, and From fields
  #  - Sort the results by the ReceivedDateTime field in descending order
  query_parameters = {'$top': '10',
                      '$select': 'receivedDateTime,subject,from,categories',
                      '$orderby': 'receivedDateTime DESC'}

  r = make_api_call('GET', get_messages_url, access_token, parameters = query_parameters)

  if (r.status_code == requests.codes.ok):
    return r.json()
  else:
    return "{0}: {1}".format(r.status_code, r.text)

我现在可以检索电子邮件

1 个答案:

答案 0 :(得分:0)

首先,您需要List Outlook categories来查找要更新的类别ID。

GET /me/outlook/masterCategories

然后您可以通过调用此端点Update Outlook category

PATCH /me/outlook/masterCategories/{id}

这里是example