Based on Microsoft Graph REST API ( for more info see : [https://docs.microsoft.com/en-us/graph/api/resources/message?view=graph-rest-1.0]).\\

!Microsoft Graph Application registration
\\
It requires Microsoft Graph Application registration. Start at the Microsoft azure portal:\\
[https://azure.microsoft.com/en-us/features/azure-portal/]\\
\\
__Application registration__: Go to the App registrations and click on New registration:\\
\\
[attachments|new_registration.png]\\
\\
Name it. Select the Multitenant and personal Microsoft accounts type. The redirect url must ends with :register_microsoft_graph_api/. Then click on register.\\
\\
[attachments|register_app.png]\\
\\
Under the redirect url configuration enable the __Access Token__ to be issued by the authorization endpoint:\\
\\
[attachments|SMTP Microsoft Graph XOAUTH 2 Integration/enable_access_token.png]\\
\\
__API permissions__ :\\
\\
MicrosoftMails task support OAuth 2.0 client credential grant. It requests the permissions from a directory admin. Go to the API permission. Click on Add permission, select Microsoft Graph.Choose "Application permissions".\\
\\
[attachments|permission_microsoft_graph.png]\\
[attachments|permission_app_permissions.png]\\
[attachments|permission_user.png]\\
[attachments|permissions_mail.png]\\
\\
To grant permissison for CrushFTP click on "Get Admin consent" button. Make sure your Webinterface host and port match with the host and port specified in App registration's redirect url.\\
\\
[attachments|admin_consent.png]\\
[attachments|client_id.png]\\

\\
You need to login with an admin account and grant permissions for your CrushFTP. Any changes on Azure App Registration -> API permissions require new admin consent.  
\\
!Settings\\
\\
[attachments|mail_task.png]\\
\\
Client ID, Client Secret, Tenant : Authentication related setting. Azure App registration -> Overview.\\
Folder : Supports subfolders too like Folder/Subbolder/SubSubFolder\\
Search query : Search settings for messages. See [https://docs.microsoft.com/en-us/graph/query-parameters#search-parameter].\\
After processing copy message to this mailbox: Supports subfolders too.\\
\\
Variable patterns:\\
\\
Message related variables:\\
{{{
{mail_id}, {mail_createdDateTime}, {mail_lastModifiedDateTime}, {mail_hangeKey}, {mail_sentDateTime}, {mail_receivedDateTime}, {mail_hasAttachments}, {mail_internetMessageId}, {mail_subject}, {mail_body_content}, {mail_body_type}, {mail_importance}, {mail_parentFolderId}, {mail_conversationId}, {mail_isRead}, {mail_isDraft}, {mail_sender}, {mail_from} , {mail_to}, {mail_cc}, {mail_bcc}, {mail_reply_to}
}}} \\
\\ 
Attachment related variables:\\
{{{
{id}, {contentType}, {size, name}, {lastModifiedDateTime}
}}}