Outlook Mail (Office 365) Connector
Documentation
Version: 2
Documentation

Outlook Mail (Office 365) Connector - Source Code


<?xml version="1.0" encoding="utf-8"?>
<ApiConfig Name="Outlook Mail (Office 365)"
           Desc="Outlook Mail Connector (Office 365) can be used to integrate Office 365 Outlook Mail API in your App / BI Tools. You can download attachment, read / search Emails, Users, MailFolders, Send email and more."
           Slug="outlook-mail-connector"
           Id="8b5786b9-5dee-4420-8b12-8a7058d63148"
           Logo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFyWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNy4yLWMwMDAgNzkuMWI2NWE3OSwgMjAyMi8wNi8xMy0xNzo0NjoxNCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIiB4bWxuczpwaG90b3Nob3A9Imh0dHA6Ly9ucy5hZG9iZS5jb20vcGhvdG9zaG9wLzEuMC8iIHhtcDpDcmVhdG9yVG9v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NIKttj/DNn+XMjIcjRNV+hWNJ3HDMVh9Awsck9aDfX9Wgb2oke7os57HdGBRuOLZ/41VffSMC891kq8oYbyXQD7YkdPZH8D6OE4V8auwDlCp44pGkE8SLgxWL2AticoF644UguleQrA0TgXCkL9xRFQ3FPlus9Ymate8EyKPn+Qvkgx15HSwDaylB/LDL6DBplocXRsoxGBRD1YSasMJ1JbjknqwA/kfoecrgPvRoiHfHsifPi9I+sXMrZLt41z5mSM38soMe+WsBNacUPlO94xSQIe8Ub9NOfQYLGrAAg6o7s92KcHXBwrAx6F/1X1c0TB2+9nyj74+kO/2bpgidbyXUDOIIbCGOXODRrnyAV1aGK/u1efCYNEI1vmCZnBO3QSS0EAeQ58PR20JOlv+6Mrd6nfnhynWTvXPiR3jyucOduC0UA3Wq0FSn0VoXOiUD+p/Tz4XBothsEJRHU6ozjWHC8Eq1L/30eB8FCKzez9EPjng99IVy/blh87cJr2IotImS6LS5QcLXPbwagDd+h2NHwaLvWCBxVFKQ9tPKRtBMmr3IW6N3fZTZRNW7stbuCBU7v6inyjxSQ+BfJAD5yYZsGaHyNd8tj8fMCFfBI2mDoPVX8ACcZf0wPt4MdiYrAVfIp/GHv3NnEDxiCXRqtffC5H/sjhOvWdyoFg21JF7oytY3x4uXBqK/p4ppckbMFj9HCzwPbqGA+p/lqbZ0PaD3KphfidL5q3cn28/K0iaONaVrwu9rJ96VFYPmBQBBevBwsKiQngQsDBYWBgsLAwWHgQs6vVvZxd0albnQrcAAAAASUVORK5CYII="
           Version="2"
           EngineVersion="11">
  <VersionHistory>
	<Change Date="2024-06-24" Type="New">Lookup operation might fail if you query Users or other Objects by ID becuase its passing general OData options in URL (e.g. $top)</Change>
	<Change Date="2024-06-24" Type="New">New endpoint download_message_attachments to get multiple attachments by search condition</Change>
	<Change Date="2024-06-24" Type="New">Allow to get messages from a specific folder for get_messages and get_my_messages endpoints</Change>
    <Change Date="2024-06-24" Type="Fix">Updated datatypes for some endpoint columns (previously they were all string types)</Change>
    <Change Date="2023-03-28" Type="New">Initial version</Change>
  </VersionHistory>

  <ServiceUrls>
    <ServiceUrl Name="Microsoft Graph API v1.0" Url="https://graph.microsoft.com/v1.0" />
  </ServiceUrls>

  <Auths>
    <Auth Name="UserCreds" Label="User Credentials" Type="OAuth" Desc="OAuth App must be created in Microsoft Azure AD. These settings typically found here https://docs.microsoft.com/en-us/graph/auth-register-app-v2."
          HelpLink="https://docs.microsoft.com/en-us/graph/auth-register-app-v2"
          ConnStr="Provider=Custom;OAuthVersion=OAuth2;GrantType=Default;Scope=[$Scope$];ScopeSeparator={space};"
          TestEndPoint="get_my_info">
      <Notes>
        <![CDATA[<p>Firstly, login into Azure Portal and there create an OAuth application:
<p />
<ol>
  <li>Go to <a target="_blank" href="https://portal.azure.com/#home"><b>Azure Portal</b></a> and login there.</li>
  <li>Then go to <a target="_blank" href="https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview"><b>Azure Active Directory</b></a>.</li>
  <li>On the left side click menu item <b><a target="_blank" href="https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps">App registrations</a></b></li>
  <li>Then proceed with clicking <b>New registration</b>.</li>
  <li>Enter a name for your application.</li>
  <li>Select the account types to support with the <b>Supported account types</b> option.</li>
  <li>In <b>Redirect URI</b>, select <i>Web</i>.</li>
  <li>In the textbox enter <b>https://zappysys.com/oauth</b> as the Redirect URI or another valid redirect URL.</li>
  <li>Use this same Redirect URI in the <b>Redirect URL - Must Match App Redirect URL</b> grid row.</li>  
  <li>Copy <b>Client ID</b> and paste it into the API Connection Manager configuration grid in the <b>Client ID</b> row.</li>
  <li>Click on the <b>Endpoints</b> link and copy the <b>OAuth 2.0 authorization endpoint (v2)</b> URL to the <b>Authorization URL</b> grid row. Usually it looks similar to this:
     <ul>
       <li>https://login.microsoftonline.com/daed1250-xxxx-xxxx-xxxx-ef0a982d3d1e/oauth2/v2.0/authorize</li>
     </ul>
  </li>
  <li>Copy the <b>OAuth 2.0 token endpoint (v2)</b> URL to the <b>Token URL</b> grid row. Usually it looks similar to this:
     <ul>
       <li>https://login.microsoftonline.com/daed1250-xxxx-xxxx-xxxx-ef0a982d3d1e/oauth2/v2.0/token</li>       
     </ul>
  </li>
  <li>Close "Endpoints" popup and create a </i>Client Secret</i> in the <b>Certificates & secrets</b> tab.</li>
  <li>Proceed by clicking <b>New client secret</b> and setting expiration period. Copy the client secret and paste it into configuration grid in <b>Client Secret</b> row.</li>
  <li>Now lets setup permissions for the app. Click on <b>API Permissions</b> and on the page click Plus Sign <b>Add Permission</b></li>
  <li>Click on <b>Microsoft Graph API</b> and then choose <b>Delegated Permissions</b></li>
  <li>on Permission list page search or choose permissions as needed. We need to enable following Permissions from 3 Sections (i.e. OpenId Permissions, Mail Permissions and Users Permissions).</li>
  <li>Make sure you have checked below permissions (If you do not need Write feature then you can skip Write scopes)
<pre>
offline_access
email
openid
profile 
Mail.Read
Mail.Read.Shared
Mail.ReadBasic
Mail.ReadBasic.Shared
Mail.ReadWrite
Mail.ReadWrite.Shared
Mail.Send
Mail.Send.Shared
User.Read
User.ReadBasic.All
  </pre>  
  
  </li>
  <li>Click <b>Generate Token</b> to generate tokens.
    <div style="background-color: #f5f2c4; border-style: solid; border-color: #000000; border-width: 1px; margin-top: 3px; margin-bottom: 6px; padding: 6px;">
		<b>NOTE:</b> If you are planning to use your current data connection/token for automated processes, we recommend that you use a generic account for token generation when the login box appears (e.g. sales_automation@mycompany.com instead of bob_smith@mycompany.com). When you use a personal account which is tied to a specific employee profile and that employee leaves the company, the token may become invalid and any automated processes using that token will fail. Another potentially unwanted effect of using a personal token is incorrect logging; the API calls (e.g. Read, Edit, Delete, Upload) made with that token will record the specific user as performing the calls instead of an automated process.
    </div>  
  </li>
  
  <li>That's it!</li>
</ol>
]]>
      </Notes>
      <Params>
        <Param Name="AuthUrl" Label="Authorization URL" Required="True" Options="For Single-Tenant Use=https://login.microsoftonline.com/{ENTER-TENANT-ID-HERE}/oauth2/v2.0/authorize;For Multi-Tenant Use=https://login.microsoftonline.com/common/oauth2/v2.0/authorize" />
        <Param Name="TokenUrl" Label="Token URL" Required="True" Options="For Single-Tenant Use=https://login.microsoftonline.com/{ENTER-TENANT-ID-HERE}/oauth2/v2.0/token;For Multi-Tenant Use=https://login.microsoftonline.com/common/oauth2/v2.0/token"  />
        <Param Name="ClientId" Label="Client ID" Required="True" />
        <Param Name="ClientSecret" Label="Client Secret" Secret="True"/>
        <Param Name="RefreshTokenFilePath" Label="Refresh Token File Path" Hidden="True" Desc="If you cant fit long refresh token in ConnectionString from your program then use this. Supply three properies in json format (i.e. save this in file { &quot;access_token&quot;: &quot;YOUR_ACCESS_TOKEN&quot;, &quot;refresh_token&quot;: &quot;YOUR_REFRESH_TOKEN&quot;, &quot;expires_in&quot;: 3600 } )"/>
        <Param Name="Scope"
               Required="True"
               Options="offline_access;email;Mail.Read;Mail.Read.Shared;Mail.ReadBasic;Mail.ReadBasic.Shared;openid;profile;User.Read;User.ReadBasic.All;Mail.ReadWrite;Mail.ReadWrite.Shared;Mail.Send;Mail.Send.Shared"
               MultiSelectSeparator=" "
               MultiSelect="True"
               Value="offline_access~email~Mail.Read~Mail.Read.Shared~Mail.ReadBasic~Mail.ReadBasic.Shared~openid~profile~User.Read~User.ReadBasic.All~Mail.ReadWrite~Mail.ReadWrite.Shared~Mail.Send~Mail.Send.Shared~"
               Desc="Permissions you want to use."
               Example="offline_access~email~Mail.Read~Mail.Read.Shared~Mail.ReadBasic~Mail.ReadBasic.Shared~openid~profile~User.Read~User.ReadBasic.All~Mail.ReadWrite~Mail.ReadWrite.Shared~Mail.Send~Mail.Send.Shared~"
               HelpLink=""/>
        <Param Name="ReturnUrl" Label="ReturnUrl - Must Match App Redirect URL" Options="https://zappysys.com/oauth"
               Desc="The ReturnUrl must match the URL on the Authentication page for your Application (in Azure Portal)" />
        <!--below not exposed as root level property in HTTP Connection so use as placeholder-->
        <Param Name="RetryMode" Value="RetryWhenStatusCodeMatch" Options="None;RetryAny;RetryWhenStatusCodeMatch;" Hidden="True" />
        <Param Name="RetryStatusCodeList" Value="429|503" Hidden="True" />
        <Param Name="RetryCountMax" Value="5" Hidden="True" />
        <Param Name="RetryMultiplyWaitTime" Value="True" Hidden="True" />
        <Param Name="ExtraAttributesForAuthRequest"
			         Label="Login Prompt Option"
               Options="None=;Force login prompt=prompt=login;Force permission select=prompt=consent;"
               Desc="Choose this if you want to force login prompt or permission prompt."
               HelpLink="https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow"/>
      </Params>
    </Auth>
    <Auth Name="AppCreds" Label="Application Credentials" Type="OAuth" Desc="OAuth App must be created in Microsoft Azure AD. These settings typically found here https://docs.microsoft.com/en-us/graph/auth-v2-service"
          HelpLink="https://docs.microsoft.com/en-us/graph/auth-v2-service"
          ConnStr="Provider=Custom;OAuthVersion=OAuth2;ScopeSeparator={space};GrantType=ClientCredentials;Scope=[$Scope$];ScopeSeparator={space};"
          TestEndPoint="get_my_info">
      <Notes>
        <![CDATA[]]>
      </Notes>
      <Params>
        <Param Name="TokenUrl" Label="Token URL" Required="True" Options="For Single Tenant=https://login.microsoftonline.com/{ENTER-TENANT-ID-HERE}/oauth2/v2.0/token;For Multi Tenant=https://login.microsoftonline.com/common/oauth2/v2.0/token"  />
        <Param Name="ClientId" Label="Client ID" Required="True" />
        <Param Name="ClientSecret" Label="Client Secret" Secret="True" Required="True"/>
        <Param Name="Scope"
               Required="True"
               Options="offline_access;email;Mail.Read;Mail.Read.Shared;Mail.ReadBasic;Mail.ReadBasic.Shared;openid;profile;User.Read;User.ReadBasic.All;Mail.ReadWrite;Mail.ReadWrite.Shared;Mail.Send;Mail.Send.Shared"
               MultiSelectSeparator=" "
               MultiSelect="True"
               Value="offline_access~email~Mail.Read~Mail.Read.Shared~Mail.ReadBasic~Mail.ReadBasic.Shared~openid~profile~User.Read~User.ReadBasic.All~Mail.ReadWrite~Mail.ReadWrite.Shared~Mail.Send~Mail.Send.Shared~"
               Desc="Permissions you want to use."
               Example="offline_access~email~Mail.Read~Mail.Read.Shared~Mail.ReadBasic~Mail.ReadBasic.Shared~openid~profile~User.Read~User.ReadBasic.All~Mail.ReadWrite~Mail.ReadWrite.Shared~Mail.Send~Mail.Send.Shared~"
               HelpLink=""/>
        <!--below not exposed as root level property in HTTP Connection so use as placeholder-->
        <Param Name="RetryMode" Value="RetryWhenStatusCodeMatch" Options="None;RetryAny;RetryWhenStatusCodeMatch;" Hidden="True" />
        <Param Name="RetryStatusCodeList" Value="429|503" Hidden="True" />
        <Param Name="RetryCountMax" Value="5" Hidden="True" />
        <Param Name="RetryMultiplyWaitTime" Value="True" Hidden="True" />
      </Params>
    </Auth>
  </Auths>


  <Template>
     <Param Name="UserIdParam" Label="User ID or Email" 
		  Value="me" Required="True" 
		  Type="Placeholder"
          Desc="The Microsoft Mail user ID GUID or email address for the account to read messages from. (Examples: '4ff54a77-9c09-4274-958f-83bdc0a53900' or 'first.last@domain.com')"
          OptionsEndPoint="get_users"
		  OptionsEndPointValueColumn="Id"
		  OptionsEndPointLabelColumn="DisplayName" 
		  ValueTemplate="&lt;&lt;{$value$}|~|Eq|~|me|~|me|~|users/{$value$},FUN_IF&gt;&gt;"
		  />
	<Param Name="MailFolderIdParam"           
		  OptionsEndPoint="get_mailfolders"
		  OptionsEndPointParameters="UserId=[$UserId$]"
		  OptionsEndPointValueColumn="Id"
		  OptionsEndPointLabelColumn="DisplayName"
		  ValueTemplate="mailfolders('{$value$}')/"
		  />
		  
    <Param Name="MessageColumnsParam" Key="$select" Label="Selected Columns" Type="Query"
	  OptionsEndPoint="get_table_columns" OptionsEndPointValueColumn="Name" OptionsEndPointParameters="Filter=message" 
	  OptionSort="ASC"
      MultiSelect="True" MultiSelectSeparator=","
      DataType="DT_WSTR" Length="4000"
      Desc="Select the individual columns to be included in the response, to reduce the response size and increase performance"
      HelpLink="https://zappysys.com/links?url=https://learn.microsoft.com/en-us/graph/query-parameters" />
	  
    <Param Name="UserColumnsParam" Key="$select" Label="Selected Columns" Type="Query"
	  OptionsEndPoint="get_table_columns" OptionsEndPointValueColumn="Name" OptionsEndPointParameters="Filter=user" 
	  OptionSort="ASC"
      MultiSelect="True" MultiSelectSeparator=","
      DataType="DT_WSTR" Length="4000"
      Desc="Select the individual columns to be included in the response, to reduce the response size and increase performance"
      HelpLink="https://zappysys.com/links?url=https://learn.microsoft.com/en-us/graph/query-parameters" />
	  
    <Param Name="MailFolderColumnsParam" Key="$select" Label="Selected Columns" Type="Query"
	  OptionsEndPoint="get_table_columns" OptionsEndPointValueColumn="Name" OptionsEndPointParameters="Filter=mailFolder" 
	  OptionSort="ASC"
      MultiSelect="True" MultiSelectSeparator=","
      DataType="DT_WSTR" Length="4000"
      Desc="Select the individual columns to be included in the response, to reduce the response size and increase performance"
      HelpLink="https://zappysys.com/links?url=https://learn.microsoft.com/en-us/graph/query-parameters" />

    <EndPoint Name="ODataGeneralOptions">
      <Params>
        <Param Name="OrderBy" Key="$orderby" Label="Order By" Type="Query"
          Options="None=;AscendingOrder=SomeColumn asc;DescendingOrder=SomeColumn desc;"
          DataType="DT_WSTR" Length="200"
          Desc="Order the specified column by ascending or descending order"
          HelpLink="https://zappysys.com/links?url=https://learn.microsoft.com/en-us/graph/query-parameters" />
        <Param Name="SearchCriteria" Key="$filter" Label="Search Criteria" Type="Query"
          Options="None=;Equal Search=SomeColumn eq 'SomeValue';Substring Search=substringof(SomeField,'abc');Starts With=startswith(SomeField, 'abc')"
          Desc="Data filter (e.g. somecolumn -eq 'somevalue')"
          HelpLink="https://zappysys.com/links?url=https://learn.microsoft.com/en-us/graph/query-parameters" />
        <Param Name="PageSize" Key="$top" Label="Page Size" Type="Query" Value="100"
          DataType="DT_I4" Desc="The number of records to include in each page of results"
          HelpLink="https://zappysys.com/links?url=https://learn.microsoft.com/en-us/graph/query-parameters" />
      </Params>
    </EndPoint>



    <EndPoint Name="SearchMessageParams"
		Headers="Prefer: outlook.body-content-type=[$EmailBodyFormat$]"
	>
	  <Params>
		<!-- KQL funtionality is still buggy in Mail API so commented
		<Param Name="SearchCriteriaKQL" Key="$search" Label="Search Criteria (using KQL) - Simple expression" Type="Query"
			Options="None=;
			Search Text in Body or Subject=&quot;invoice G020427950 is ready&quot;;
			From=from:some@abcinc.onmicrosoft.com;
			To=to:some@abcinc.onmicrosoft.com;
			Cc=cc:some@abcinc.onmicrosoft.com;
			Bcc=bcc:some@abcinc.onmicrosoft.com;
			Participants (From, To, Cc, Bcc)=participants:npatel@zappysys.onmicrosoft.com;
			Mail Received on=received:07/23/2018;
			Mail Sent on=sent:07/23/2018;
			Subject Contains=subject:daily report;"
			HelpLink="https://learn.microsoft.com/en-us/graph/search-query-parameter?tabs=http#using-search-on-message-collections"
			ValueTemplate="&quot;{$value$}&quot;"
		>
		
		</Param>
		-->
		
        <Param Name="SearchCriteria" Key="$filter" Label="Search Criteria" Type="Query"
              Options="None=;
			  From specific email='from/emailAddress/address eq 'microsoft-noreply@microsoft.com';
			  Has Attachments=hasAttachments eq true;
              Has Attachments, Sent After, and Subject containing 'party'=hasAttachments eq true and sentDateTime gt 2023-03-01 and contains(subject, 'party');
              Received before=receivedDateTime lt 2023-02-01;
              Sent after=sentDateTime gt 2023-03-01;
			  Sent after (dynamic)=sentDateTime gt &lt;&lt;yearstart+1d|~|yyyy-MM-dd,FUN_TO_DATE&gt;&gt;;
			  Search by Internet MessageId=contains(internetMessageId,''59e62584-e364-453a-8444-5591a324ddaa@az.centralus.production.microsoft.com'')
              Has attachment(s)=hasAttachments eq true;
              Subject contains 'case'=contains(subject, 'case');
              Subject starts with 'Your'=startsWith(subject, 'Your');
              Subject does not start with 'Your'=not(startsWith(subject, 'Your'));
              Only normal importance=importance eq 'normal';
              Only low importance=importance eq 'low';
              Only high importance=importance eq 'high';
              Only if delivery receipt requested=isDeliveryReceiptRequested eq true;
              Only if delivery receipt not requested=isDeliveryReceiptRequested eq false;
              Only if read receipt requested=isReadReceiptRequested eq true;
              Only if read receipt not requested=isReadReceiptRequested eq false;
              Only if message is read=isRead eq true;
              Only if message is unread=isRead eq false;
              Only if message is a draft=isDraft eq true;
              Only if message is not a draft=isDraft eq false;
              Body content contains=contains(body/content, 'money');
              From Sender 'John Doe'=sender/emailAddress/name eq 'John Doe'"
              Desc="Data filter (e.g. somecolumn -eq 'somevalue'), you can use Date time functions for dynamic date. You can use keywords like now,today,yesterday,monthstart,monthend,yearstart,yearend,weekstart,weekend along with operator + / - [hour,minute,second,day,month,year]"
              HelpLink="https://learn.microsoft.com/en-us/graph/filter-query-parameter?tabs=http" />        
        <Param Name="EmailBodyFormat" Label="Email Body Format" Type="Placeholder" Value="html" Required="True"
              Options="html;text" />
		
		<Param Name="UserId" Template="UserIdParam"/>
		<Param Name="MailFolderId" Template="MailFolderIdParam" />           
		 
      </Params>	
	</EndPoint>

    <EndPoint Name="MessageOutputColumns">
      <Params>
        <Param Name="SelectedColumns" Template="MessageColumnsParam" />
        <Param Name="EnableArrayFlattening" Value="True" Type="Property" Desc="Enables deep array flattening for selected filtered hierarchy. When you turn on this property it will flatten each property of each array item and expose as column (e.g. If you have array property called tags and value is ['red','blue','yellow'] and if you turn on array flatterning then may see columns tags.1, tags.2, tags.3... tags.N in the output. You can control how many array items you want to flatten by setting MaxArrayItemsToFlatten property." />
        <Param Name="MaxArrayItemsToFlatten" Value="5" Type="Property" />
      </Params>
      <OutputColumns>
        <Column Name="id" DataType="DT_WSTR" Label="Id" Length="1000" />
        <Column Name="receivedDateTime" DataType="DT_DBTIMESTAMP" Label="ReceivedDateTime" />
        <Column Name="hasAttachments" DataType="DT_BOOL" Label="HasAttachments" />
        <Column Name="subject" DataType="DT_WSTR" Label="Subject" Length="800" />
        <Column Name="bodyPreview" DataType="DT_WSTR" Label="BodyPreview" Length="4000" />
        <Column Name="sender.emailAddress.name" DataType="DT_WSTR" Label="SenderEmailAddressName" Length="800" />
        <Column Name="sender.emailAddress.address" DataType="DT_WSTR" Label="SenderEmailAddress" Length="800" />		
        <Column Name="importance" DataType="DT_WSTR" Label="Importance" Length="500" />
        <Column Name="sentDateTime" DataType="DT_DBTIMESTAMP" Label="SentDateTime" />		
        <Column Name="createdDateTime" DataType="DT_DBTIMESTAMP" Label="CreatedDateTime" />
        <Column Name="lastModifiedDateTime" DataType="DT_DBTIMESTAMP" Label="LastModifiedDateTime" />
        <Column Name="changeKey" DataType="DT_WSTR" Label="ChangeKey" Length="1000" />
		
        <Column Name="toRecipients" DataType="DT_WSTR" Label="ToRecipients" Length="1190" />
        <Column Name="ccRecipients" DataType="DT_WSTR" Label="CcRecipients" Length="1190" />
        <Column Name="bccRecipients" DataType="DT_WSTR" Label="BccRecipients" Length="1190" />
		
		
		
        <Column Name="toRecipients.1.emailAddress.address" DataType="DT_WSTR" Label="ToRecipient1" Length="200" />
        <Column Name="toRecipients.2.emailAddress.address" DataType="DT_WSTR" Label="ToRecipient2" Length="200" />
        <Column Name="toRecipients.3.emailAddress.address" DataType="DT_WSTR" Label="ToRecipient3" Length="200" />
        <Column Name="toRecipients.4.emailAddress.address" DataType="DT_WSTR" Label="ToRecipient4" Length="200" />
        <Column Name="toRecipients.5.emailAddress.address" DataType="DT_WSTR" Label="ToRecipient5" Length="200" />
        <Column Name="ccRecipients.1.emailAddress.address" DataType="DT_WSTR" Label="CcRecipient1" Length="200" />
        <Column Name="ccRecipients.2.emailAddress.address" DataType="DT_WSTR" Label="CcRecipient2" Length="200" />
        <Column Name="ccRecipients.3.emailAddress.address" DataType="DT_WSTR" Label="CcRecipient3" Length="200" />
        <Column Name="ccRecipients.4.emailAddress.address" DataType="DT_WSTR" Label="CcRecipient4" Length="200" />
        <Column Name="ccRecipients.5.emailAddress.address" DataType="DT_WSTR" Label="CcRecipient5" Length="200" />
        <Column Name="bccRecipients.1.emailAddress.address" DataType="DT_WSTR" Label="BccRecipient1" Length="200" />
        <Column Name="bccRecipients.2.emailAddress.address" DataType="DT_WSTR" Label="BccRecipient2" Length="200" />
        <Column Name="bccRecipients.3.emailAddress.address" DataType="DT_WSTR" Label="BccRecipient3" Length="200" />
        <Column Name="bccRecipients.4.emailAddress.address" DataType="DT_WSTR" Label="BccRecipient4" Length="200" />
        <Column Name="bccRecipients.5.emailAddress.address" DataType="DT_WSTR" Label="BccRecipient5" Length="200" />
        <Column Name="categories" DataType="DT_WSTR" Label="Categories" Length="1000" />
        <Column Name="parentFolderId" DataType="DT_WSTR" Label="ParentFolderId" Length="1200" />
        <Column Name="conversationId" DataType="DT_WSTR" Label="ConversationId" Length="1200" />
        <Column Name="conversationIndex" DataType="DT_WSTR" Label="ConversationIndex" Length="1200" />
        <Column Name="isDeliveryReceiptRequested" DataType="DT_BOOL" Label="IsDeliveryReceiptRequested" />
        <Column Name="isReadReceiptRequested" DataType="DT_BOOL" Label="IsReadReceiptRequested" />
        <Column Name="isRead" DataType="DT_BOOL" Label="IsRead" />
        <Column Name="isDraft" DataType="DT_BOOL" Label="IsDraft" />
        <Column Name="webLink" DataType="DT_WSTR" Label="WebLink" Length="4000" />
        <Column Name="inferenceClassification" DataType="DT_WSTR" Label="InferenceClassification" Length="800" />
        <Column Name="internetMessageHeaders" DataType="DT_NTEXT" Label="InternetMessageHeaders" />
        <Column Name="body.contentType" DataType="DT_WSTR" Label="BodyContentType" Length="500" />
        <Column Name="body.content" DataType="DT_NTEXT" Label="BodyContent" />
        <Column Name="from.emailAddress.name" DataType="DT_WSTR" Label="FromEmailAddressName" Length="800" />
        <Column Name="from.emailAddress.address" DataType="DT_WSTR" Label="FromEmailAddress" Length="800" />
        <Column Name="replyTo" DataType="DT_WSTR" Label="ReplyTo" Length="1190" />
        <Column Name="uniqueBody.contentType" DataType="DT_WSTR" Label="UniqueBodyContentType" Length="500" />
        <Column Name="uniqueBody.content" DataType="DT_WSTR" Label="UniqueBodyContent" Length="4000" />
        <Column Name="flag.flagStatus" DataType="DT_WSTR" Label="FlagFlagStatus" Length="800" />
        <Column Name="@odata.etag" DataType="DT_WSTR" Label="ODataETag" Length="1000" />
		<Column Name="internetMessageId" DataType="DT_WSTR" Label="InternetMessageId" Length="1800" />		
      </OutputColumns>
    </EndPoint>

    <EndPoint Name="AttachmentOutputColumns">
      <OutputColumns>
        <Column Name="id" DataType="DT_WSTR" Label="Id" Length="1000" />
        <Column Name="name" DataType="DT_WSTR" Label="Name" Length="200" />
        <Column Name="contentType" DataType="DT_WSTR" Label="ContentType" Length="200" />
        <Column Name="isInline" DataType="DT_BOOL" Label="IsInline" />
        <Column Name="lastModifiedDateTime" DataType="DT_DBTIMESTAMP" Label="LastModifiedDateTime" />
        <Column Name="size" DataType="DT_I4" Label="Size" />
        <Column Name="contentId" DataType="DT_WSTR" Label="ContentId" Length="2000" />
        <Column Name="contentBytes" DataType="DT_NTEXT" Label="ContentBytes" />
        <Column Name="@odata.type" DataType="DT_WSTR" Label="ODataType" Length="200" />
        <Column Name="@odata.mediaContentType" DataType="DT_WSTR" Label="ODataMediaContentType" Length="200" />
      </OutputColumns>
    </EndPoint>

    <EndPoint Name="UserOutputColumns">
      <Params>
        <Param Name="SelectedColumns" Template="UserColumnsParam" />
      </Params>
      <OutputColumns>
        <Column Name="businessPhones" DataType="DT_WSTR" Label="BusinessPhones" Length="4000" />
        <Column Name="displayName" DataType="DT_WSTR" Label="DisplayName" Length="500" />
        <Column Name="givenName" DataType="DT_WSTR" Label="GivenName" Length="80" />
        <Column Name="jobTitle" DataType="DT_WSTR" Label="JobTitle" Length="200" />
        <Column Name="mail" DataType="DT_WSTR" Label="Mail" Length="200" />
        <Column Name="mobilePhone" DataType="DT_WSTR" Label="MobilePhone" Length="500" />
        <Column Name="officeLocation" DataType="DT_WSTR" Label="OfficeLocation" Length="500" />
        <Column Name="preferredLanguage" DataType="DT_WSTR" Label="PreferredLanguage" Length="100" />
        <Column Name="surname" DataType="DT_WSTR" Label="SurName" Length="80" />
        <Column Name="userPrincipalName" DataType="DT_WSTR" Label="UserPrincipalName" Length="200" />
        <Column Name="id" DataType="DT_WSTR" Label="Id" Length="4000" />
      </OutputColumns>
    </EndPoint>

    <EndPoint Name="MailFolderOutputColumns">
      <Params>
        <Param Name="SelectedColumns" Template="MailFolderColumnsParam" />
      </Params>
      <OutputColumns>
        <Column Name="id" DataType="DT_WSTR" Label="Id" Length="1200" />
        <Column Name="displayName" DataType="DT_WSTR" Label="DisplayName" Length="500" />
        <Column Name="parentFolderId" DataType="DT_WSTR" Label="ParentFolderId" Length="1200" />
        <Column Name="childFolderCount" DataType="DT_I4" Label="ChildFolderCount" />
        <Column Name="unreadItemCount" DataType="DT_I4" Label="UnreadItemCount" />
        <Column Name="totalItemCount" DataType="DT_I4" Label="TotalItemCount" />
        <Column Name="sizeInBytes" DataType="DT_I4" Label="SizeInBytes" />
        <Column Name="isHidden" DataType="DT_BOOL" Label="IsHidden" />
      </OutputColumns>
    </EndPoint>
    
    <EndPoint Name="PaginationParams">
      <Params>
        <Param Name="PageSize" Label="PageSize" Type="Query" Value="100" Desc="The number of records to show on each page of results." Hidden="True" />
        <Param Name="DataFormat" Type="Property" Value="OData" />
      </Params>
    </EndPoint>

  </Template>


  <EndPoints>


		
	<!-- GET Tables-->	
    <EndPoint Name="get_tables"
              Label="Get Tables"
              Url="/$metadata"
			  Filter="$.edmx:Edmx.edmx:DataServices.Schema[*].EntityType[*]"
              Method="GET"
			  Desc="Get table list and its properties for Graph API"
			  ResponseFormat="Xml" 
			  CachedTtl="600"
			  >
		<OutputColumns>
			<Column Name="@Name" DataType="DT_WSTR" Label="Name" Length="500"  /> 
			<Column Name="@BaseType" DataType="DT_WSTR" Label="BaseType" Length="500"  />			
		</OutputColumns>
    </EndPoint>
	
    <EndPoint Name="get_table_columns"
              Label="Get Table Columns"
              Url="/$metadata"
              Method="GET"
			  Desc="Get table list and its properties for Graph API"
			  Filter="$.edmx:Edmx.edmx:DataServices.Schema[*].EntityType[*].Property[*]"
			  IncludeParentColumns="True"
			  ResponseFormat="Xml" 
			  CachedTtl="600"
			  >			  
		<Params>
			<Param Name="Filter" Label="Table Name" Value="" DataEndPoint="get_tables" 
			  ValueTemplate="$.edmx:Edmx.edmx:DataServices.Schema[*].EntityType[?(@@Name=='{$value$}')].Property[*]"
			  OptionsEndPoint="get_tables"
              OptionsEndPointValueColumn="name"
              OptionsEndPointLabelColumn="name"
			  OptionSort="ASC"
			/>
		</Params>	  
		<OutputColumns>
			<Column Name="P_edmx:Edmx.edmx:DataServices.Schema_EntityType_@Name" Label="EntityName" DataType="DT_WSTR" Length="500" />
			<Column Name="P_edmx:Edmx.edmx:DataServices.Schema_EntityType_@BaseType" Label="BaseType" DataType="DT_WSTR" Length="500" />
			<Column Name="@Name" DataType="DT_WSTR" Label="Name" Length="500"  />
			<Column Name="@Type" DataType="DT_WSTR" Label="Type" Length="500"  />
			<Column Name="@Nullable" DataType="DT_BOOL" Label="Nullable"  />
		</OutputColumns>
    </EndPoint>	
	
    <!-- GET MY INFO ***-->
    <EndPoint Name="get_my_info"
              Label="Get My Information"
              Url="/me"
              Method="GET"
			  Desc="Get general information about the current user.">
      <OutputColumns>
        <Column Name="id" DataType="DT_WSTR" Label="Id" Length="500" />
        <Column Name="displayName" DataType="DT_WSTR" Label="DisplayName" Length="200" />
        <Column Name="givenName" DataType="DT_WSTR" Label="GivenName" Length="200" />
        <Column Name="surname" DataType="DT_WSTR" Label="SurName" Length="200" />
        <Column Name="jobTitle" DataType="DT_WSTR" Label="JobTitle" Length="200" />
        <Column Name="mail" DataType="DT_WSTR" Label="Mail" Length="200" />
        <Column Name="userPrincipalName" DataType="DT_WSTR" Label="UserPrincipalName" Length="200" />
        <Column Name="businessPhones" DataType="DT_WSTR" Label="BusinessPhones" Length="200" />
        <Column Name="mobilePhone" DataType="DT_WSTR" Label="MobilePhone" Length="200" />
        <Column Name="officeLocation" DataType="DT_WSTR" Label="OfficeLocation" Length="500" />
        <Column Name="preferredLanguage" DataType="DT_WSTR" Label="PreferredLanguage" Length="200" />
        <Column Name="@odata.context" DataType="DT_WSTR" Label="@OdataContext" Length="2000" />
      </OutputColumns>
    </EndPoint>


    <!-- GET MESSAGES **-->
    <EndPoint Name="get_messages"
              Label="Get Messages"
              Url="/[$UserId$]/[$MailFolderId$]messages"
              Method="GET"
              Filter="$.value[*]"
			  Desc="Get the mail messages for the specified user ID or email address."
              Template="SearchMessageParams,ODataGeneralOptions, MessageOutputColumns, PaginationParams"
              HelpLink="https://learn.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0">
      <Params>
        <Param Name="UserId" Template="UserIdParam"/>
      </Params>
    </EndPoint>


    <!-- SEND MAIL -->
    <EndPoint Name="send_mail"
              Label="Send Mail"
              Url="/[$UserId$]/sendMail"
              Method="POST"
              ContentType="application/json"
              JsonRowFormat="Multicontent"
              Desc="Sends an email message."
              HelpLink="https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0">
      <LayoutMap>
        <![CDATA[<?xml version="1.0" encoding="utf-8"?>
<settings ver="3" singledataset="True">
	<dataset id="root" main="True" readfrominput="True"></dataset>
	<map name="message">
		<map src="Subject" name="subject" />
		<map name="body">
			<map src="BodyContentType" name="contentType" />
			<map src="BodyContent" name="content" />
		</map>
		<map src="ToRecipients" name="toRecipients" fragment="True" />
		<map src="CcRecipients" name="ccRecipients" fragment="True" />
		<map src="BccRecipients" name="bccRecipients" fragment="True" />
		<map src="InternetMessageHeaders" name="internetMessageHeaders" fragment="True" />
		<map src="Attachments" name="attachments" fragment="True" />
		<map src="Importance" name="importance" />
		<map src="IsDeliveryReceiptRequested" name="isDeliveryReceiptRequested" />
		<map src="IsReadReceiptRequested" name="isReadReceiptRequested" />
	</map>
	<map src="SaveToSentItems" name="saveToSentItems" />
</settings>
				]]>
      </LayoutMap>
      <Body>
        <![CDATA[{$rows$}]]>
      </Body>
      <Params>
        <Param Name="UserId" Template="UserIdParam"/>
        <Param Name="DoNotOutputEmptyNestedProperty" Type="Property" Value="True" />
        <Param Name="DoNotOutputEmptyArrayProperty" Type="Property" Value="True" />
        <Param Name="RawOutputDataRowTemplate" Type="Property" Value="{}" ValueTemplate="{Response:'Message Sent'}" />
        <Param Name="EnableRawOutputModeSingleRow" Type="Property" Value="True" />
      </Params>
      <InputColumns>
        <Column Name="Subject" DataType="DT_WSTR" Length="250" />
        <Column Name="BodyContentType" DataType="DT_WSTR" Length="8" Options="html;text" Example="html or text" />
        <Column Name="BodyContent" DataType="DT_NTEXT" />
        <Column Name="ToRecipients" DataType="DT_WSTR" Length="4000" Raw="True" Example="[{ &quot;emailAddress&quot;: { &quot;address&quot;: &quot;john.doe@domain.com&quot; }}, { &quot;emailAddress&quot;: { &quot;address&quot;: &quot;jane.doe@domain.com&quot; }}]"/>
        <Column Name="CcRecipients" DataType="DT_WSTR" Length="4000" Raw="True" Example="[{ &quot;emailAddress&quot;: { &quot;address&quot;: &quot;john.doe@domain.com&quot; }}, { &quot;emailAddress&quot;: { &quot;address&quot;: &quot;jane.doe@domain.com&quot; }}]"/>
        <Column Name="BccRecipients" DataType="DT_WSTR" Length="4000" Raw="True" Example="[{ &quot;emailAddress&quot;: { &quot;address&quot;: &quot;john.doe@domain.com&quot; }}, { &quot;emailAddress&quot;: { &quot;address&quot;: &quot;jane.doe@domain.com&quot; }}]"/>
        <Column Name="InternetMessageHeaders" DataType="DT_WSTR" Length="4000" Raw="True" Example="[{ &quot;name&quot;: &quot;x-custom-header-group-name&quot;, &quot;value&quot;: &quot;Nevada&quot; }, { &quot;name&quot;: &quot;x-custom-header-group-id&quot;, &quot;value&quot;: &quot;NV001&quot; }]"/>
        <Column Name="Attachments" DataType="DT_NTEXT" Raw="True" Example="[{ &quot;@odata.type&quot;: &quot;#microsoft.graph.fileAttachment&quot;, &quot;name&quot;: &quot;attachment.txt&quot;, &quot;contentType&quot;: &quot;text/plain&quot;, &quot;contentBytes&quot;: &quot;SGVsbG8gV29ybGQh&quot; }]"/>
        <Column Name="Importance" DataType="DT_WSTR" Length="10" />        
        <Column Name="IsDeliveryReceiptRequested" DataType="DT_BOOL" />
        <Column Name="IsReadReceiptRequested" DataType="DT_BOOL" />
        <Column Name="SaveToSentItems" DataType="DT_BOOL" />
      </InputColumns>
      <OutputColumns>
        <Column Name="Id" DataType="DT_WSTR" />
        <Column Name="Response" DataType="DT_WSTR" Length="255" />
      </OutputColumns>
    </EndPoint>


    <!-- GET MY MAIL FOLDERS -->
    <EndPoint Name="get_my_mailfolders"
              Label="Get My Mail Folders"
              Url="/me/mailFolders"
              Method="GET"
              Filter="$.value[*]"
			        Desc="Get the list of mail folders for the current user."
              Template="ODataGeneralOptions, MailFolderOutputColumns, PaginationParams"
              HelpLink="https://learn.microsoft.com/en-us/graph/api/user-list-mailfolders?view=graph-rest-1.0">
    </EndPoint>

    <!-- the following format:
         https://graph.microsoft.com/v1.0/users/{some-use-id}/mailfolders/{some-folder-id}
         does not seem to be supported, only /me/mailfolders/{some-folder-id} Works. Revisit this when
	-->
		 
    <!-- GET MY MAIL FOLDER BY ID -->
    <EndPoint Name="get_my_mailfolder"
              Label="Get Mail Folder by Id"
              Url="/me/mailFolders/[$MailFolderId$]"
              Method="GET"
			        Desc="Get the mail folder specified by the mail folder Id."
              Template="MailFolderOutputColumns"
              HelpLink="https://learn.microsoft.com/en-us/graph/api/mailfolder-get?view=graph-rest-1.0">
      <Params>
        <Param Name="MailFolderId" ReadAs="Id" Label="Mail Folder Id" IsKey="True" Required="True" Type="Placeholder" Desc="The Microsoft Mail mail folder ID for the mail folder." />
      </Params>
    </EndPoint>


    <!-- GET USERS -->
    <EndPoint Name="get_users"
              Label="Get Users"
              Url="/users"
              Method="GET"
              Filter="$.value[*]"
			        Desc="Get the list of users."
              Template="ODataGeneralOptions, UserOutputColumns, PaginationParams"
              HelpLink="https://learn.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0">
    </EndPoint>


    <!-- GET USER BY ID -->
    <EndPoint Name="get_user"
              Label="Get User by Id"
              Url="/[$UserId$]"
              Method="GET"
			  Desc="Get a specific user."
              Template="UserOutputColumns"
              HelpLink="https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0">
      <Params>
        <Param Name="UserId" Template="UserIdParam" IsKey="True" ReadAs="Id" />
      </Params>
    </EndPoint>


    <!-- GET MAIL FOLDERS ***-->
    <EndPoint Name="get_mailfolders"
              Label="Get Mail Folders"
              Url="/[$UserId$]/mailFolders"
              Method="GET"
              Filter="$.value[*]"
			        Desc="Get the list of mail folders for the specified user Id."
              Template="ODataGeneralOptions, MailFolderOutputColumns, PaginationParams"
              HelpLink="https://learn.microsoft.com/en-us/graph/api/user-list-mailfolders?view=graph-rest-1.0">
      <Params>
        <Param Name="UserId" Template="UserIdParam"/>
      </Params>
    </EndPoint>


    <!-- GET MY MESSAGES ****-->
    <EndPoint Name="get_my_messages"
              Label="Get My Messages"
              Url="/me/[$MailFolderId$]messages"
              Method="GET"
              Filter="$.value[*]"
			  Desc="Get the mail messages for the current user."
              Template="SearchMessageParams,ODataGeneralOptions, MessageOutputColumns, PaginationParams"
              HelpLink="https://learn.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0">
      <Params>

      </Params>
    </EndPoint>

    
    <!-- GET MY MESSAGE BY ID ****-->
    <EndPoint Name="get_my_message"
              Label="Get My Message by Id"
              Url="/me/messages/[$MessageId$]"
              Method="GET"
			        Desc="Get the mail message by message Id for the specified user ID or email address."
              Template="MessageOutputColumns"
              Headers="Prefer: outlook.body-content-type=[$EmailBodyFormat$]"
              HelpLink="https://learn.microsoft.com/en-us/graph/api/message-get?view=graph-rest-1.0">
      <Params>
        <Param Name="MessageId" Label="Message Id" ReadAs="Id" IsKey="True" Required="True" Type="Placeholder" Desc="The Microsoft Mail message ID GUID for the message to read. (Example: 'c3220464-7209-453c-8840-3cf4de0afaa6')" />
        <Param Name="EmailBodyFormat" Label="Email Body Format" Type="Placeholder" Value="html" Required="True"
               Options="html;text" />
      </Params>
    </EndPoint>

    <!-- GET MESSAGE ATTACHMENT LIST **-->
    <EndPoint Name="get_message_attachments"
              Label="Get Message Attachments"
              Url="/[$UserId$]/messages/[$MessageId$]/attachments"
              Method="GET"
              Filter="$.value[*]"
			        Desc="Get the list of attachments linked to the specified message Id."
              Template="ODataGeneralOptions, AttachmentOutputColumns, PaginationParams"
              HelpLink="https://learn.microsoft.com/en-us/graph/api/message-list-attachments?view=graph-rest-1.0">
      <Params>
		<Param Name="UserId" Template="UserIdParam" />
        <Param Name="MessageId" ReadAs="Id" Label="Message ID" IsKey="True" Required="True" Type="Placeholder" Desc="The message Id for which to get attachments from." />
      </Params>
    </EndPoint>


    <!-- GET A SPECIFIC MESSAGE ATTACHMENT *-->
    <EndPoint Name="get_message_attachment"
              Label="Get Message Attachment"
			        Desc="Get a specific attachment linked to the specified message Id."
              Url="/[$UserId$]/messages/[$MessageId$]/attachments/[$AttachmentId$]"
              Method="GET"
              Template="AttachmentOutputColumns"
              HelpLink="https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-1.0">
      <Params>
	  	<Param Name="UserId" Template="UserIdParam" /> 
        <Param Name="MessageId" Label="Message ID" Required="True" Type="Placeholder" Desc="The message Id for which to get the attachment from." />
        <Param Name="AttachmentId" IsKey="True" Label="Attachment ID" Required="True" Type="Placeholder" Desc="The attachment Id for the attachment to get." />
      </Params>
    </EndPoint>


    <!-- DOWNLOAD A SPECIFIC MESSAGE ATTACHMENT *-->
    <EndPoint Name="download_message_attachment"
              Label="Download Message Attachment (Single File)"
			        Desc="Download a specific attachment linked to the specified message Id."
              Url="/[$UserId$]/messages/[$MessageId$]/attachments/[$AttachmentId$]/$value"
              Method="GET"
              HelpLink="https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-1.0">
      <Params>
		<Param Name="UserId" Template="UserIdParam" />
        <Param Name="MessageId" Label="Message ID" Required="True" Type="Placeholder" Desc="The message Id for which to get the attachment from." />
        <Param Name="AttachmentId" IsKey="True" Label="Attachment ID" Required="True" Type="Placeholder" Desc="The attachment Id for the attachment to get." />
        <Param Name="RequestTimeoutMs" Type="Property" Desc="Timeout in milliseconds after which download stops" Value="7200000" Required="True" Hidden="True" />
        <Param Name="FileOverwriteMode" Type="Property" Value="AlwaysOverwrite" Required="True" />
        <Param Name="TargetFilePath" Key="ResponseDataFile" Desc="Specify a disk file path to save file as" Type="Property" Required="True" Value="" Editor="FileSave" />
        <Param Name="SaveContentAsBinary" Type="Property" Value="True" Hidden="True" />
        <Param Name="RawOutputDataRowTemplate" Type="Property" Value="{Status:'Downloaded'}" />
        <Param Name="EnableRawOutputModeSingleRow" Type="Property" Value="True" />
      </Params>
      <OutputColumns>
		<Column Name="data" DataType="DT_NTEXT" Label="Data" />
		<Column Name="Status" DataType="DT_STR"  />
      </OutputColumns>
    </EndPoint>
	
		
    <EndPoint Name="download_message_attachments"
          Label="Download Message Attachments (Multiple Files) - Using Search Condition"
		  Url="/[$UserId$]/[$MailFolderId$]messages"
          Method="GET"
		  Editor="FolderOpen"
          Filter="$.value[*]"
          ContentType="application/json"
          Desc="Downloads multiple attachments for a specified search condition to select Mails"
          Template="SearchMessageParams,ODataGeneralOptions, PaginationParams"
          HelpLink="">
	  <Params>
		
		<Param Name="UserId" Template="UserIdParam" />		
		<Param Name="MailFolderId" Template="MailFolderIdParam"/>		  
		
		
		<Param Name="OverwriteFile" Value="True" Options=";True;False"/>		
		<Param Name="SaveFolder" Value="c:\temp" Desc="Specify a disk folder path to save file(s) to" Required="True" Editor="FolderOpen"/>		
	  </Params>
      <EndPoint Name="child_message_attachments"
				Url="/[$UserId$]/[$MailFolderId$]messages/[$parent.id$]/attachments"
                Method="GET"
				IncludeParentColumns="True"
				Filter="$.value"
				Desc="See contentBytes column - it invokes FUN_FILE_WRITE_BINARY_SAFE to save Base64 bytes to file."
				>		
		  <Params>
			 <Param Name="UserId" ValueTemplate="&lt;&lt;{$value$}|~|Eq|~|me|~|me|~|users/{$value$},FUN_IF&gt;&gt;"/>
			 <Param Name="MailFolderId"  ValueTemplate="mailfolders('{$value$}')/"/>			  
		  </Params>	
      </EndPoint>
	  
		<OutputColumns>
			<Column Name="id" Label="Id" DataType="DT_STR" Length="255" />
			<Column Name="p1_id" Label="MessageId" DataType="DT_STR" Length="255" />
			<Column Name="name" Label="Name" DataType="DT_WSTR" Length="500" />
			<Column Name="contentId" Label="ContentId" DataType="DT_STR" Length="255" />
			<Column Name="contentType" Label="ContentType" DataType="DT_STR" Length="255" />
			<Column Name="contentLocation" Label="ContentLocation" DataType="DT_STR" Length="1000" />
			<Column Name="isInline" Label="IsInLine" DataType="DT_BOOL"  />
			<Column Name="lastModifiedDateTime" Label="LastModifiedDateTime" DataType="DT_DBTIMESTAMP"  />
			
			<Column Name="size" Label="Size" DataType="DT_I4"  />

			<Column Name="name" Label="SavedPath" DataType="DT_WSTR" 
				ValueTemplate="[$SaveFolder$]\[$parent.contentId$]_{$value$}" />
				
			<Column Name="contentBytes" Label="SavedSize" DataType="DT_I8" 
				ValueTemplate="&lt;&lt;[$SaveFolder$]\[$parent.contentId$]_[$parent.name$]|~|{$value$}|~|[$OverwriteFile$],FUN_FILE_WRITE_BINARY_SAFE&gt;&gt;" />
		</OutputColumns>	  

    </EndPoint> 
	
	
  </EndPoints>


  <Tables>
    <Table Name="MyMessages"
           SelectEndPoint="get_my_messages"
           LookupEndPoint="get_my_message"
           InsertEndPoint="send_mail"
           />
    <Table Name="MyMailFolders"
           SelectEndPoint="get_my_mailfolders"
           LookupEndPoint="get_my_mailfolder"
           />
    <Table Name="Users"
           SelectEndPoint="get_users"
           LookupEndPoint="get_user"
           />		   
  </Tables>

  <Examples>
    
    <Example Default="True" Group="ODBC" Label="Get messages for the current user">
        <Code>
            <![CDATA[SELECT * FROM MyMessages]]>
        </Code>
    </Example>
    <Example Group="ODBC" Label="Get users">
        <Code>
            <![CDATA[select * from Users 
			--Where Id='049beb7f-03e0-4b0d-825d-73567b6786e9'	
			]]>
        </Code>
    </Example>


    <Example Group="ODBC" Label="Get a specific message from the current user's account by the message ID">
    <Code>
      <![CDATA[SELECT * FROM MyMessages
WHERE Id='AAXkADIwNzNhODMyLTZiMTQtNDhiMC02OWQzLTc5YTY5M2IyMjk0NABGAyAAAACbj2hVuNphT74wylrfU4ixBwAbUV6IxRnpQrqzrb2WfacdAAAAAAEMAAAbUV6IxRnpQrqzrb2WfacdAAAysBnxAAA=']]>
    </Code>
  </Example>
    
    <Example Group="ODBC" Label="Get messages for a specified user">
    <Code>
      <![CDATA[SELECT * FROM get_messages
WITH (UserID='firstname.lastname@domainname.com')]]>
    </Code>
  </Example>

    <Example Group="ODBC" Label="Get first 5 messages for a specified user">
      <Code>
        <![CDATA[SELECT * FROM get_messages
WITH (UserID='firstname.lastname@domainname.com', PageSize='5')]]>
      </Code>
    </Example>
	
    <Example Group="ODBC" Label="Get all messages in a specific Mail Folder">
      <Code>
        <![CDATA[SELECT * FROM get_messages
WITH (
MailFolderID='INBOX' --or use mai folder id
)]]>
      </Code>
    </Example>	

    <Example Group="ODBC" Label="Get messages with a subject line that starts with 'Announcements for'">
      <Code>
        <![CDATA[SELECT * FROM get_messages
WITH (UserID='firstname.lastname@domainname.com', SearchCriteria='startsWith(Subject,''Announcements for'')')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get messages that have at least one attachment associated with them">
      <Code>
        <![CDATA[SELECT * FROM get_messages
WITH (UserID='firstname.lastname@domainname.com', SearchCriteria='hasAttachments eq true')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get messages that are unread">
      <Code>
        <![CDATA[SELECT * FROM get_messages
WITH (UserID='firstname.lastname@domainname.com', SearchCriteria='IsRead eq false')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get messages for the current user ordered by the time they were sent in ascending order">
      <Code>
        <![CDATA[SELECT * FROM MyMessages WITH (OrderBy='sentDateTime')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get messages for the current user ordered by the time they were sent in descending order">
      <Code>
        <![CDATA[SELECT * FROM MyMessages WITH (OrderBy='sentDateTime desc')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get messages for the current user ordered by the time they were received in ascending order">
      <Code>
        <![CDATA[SELECT * FROM MyMessages WITH (OrderBy='receivedDateTime')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get messages for the current user ordered by the time they were received in descending order">
      <Code>
        <![CDATA[SELECT * FROM MyMessages WITH (OrderBy='receivedDateTime desc')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get messages for the current user ordered by the name of the sender in ascending order">
      <Code>
        <![CDATA[SELECT * FROM MyMessages WITH (OrderBy='sender/emailAddress/name')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get messages for the current user ordered by the name of the sender in descending order">
      <Code>
        <![CDATA[SELECT * FROM MyMessages WITH (OrderBy='sender/emailAddress/name desc')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get all mail folders associated with the current user">
      <Code>
        <![CDATA[SELECT * FROM MyMailFolders]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get a specific mail folder associated with the current user by its mail folder ID">
      <Code>
        <![CDATA[SELECT * FROM MyMailFolders
WHERE (Id='AAMkADIwNzNhODMyLTZiMTQtNDhiMCz4OWQzLTc5YTY5M2IyMjk0NAYuAAAAAACbj2hVuNphT74wyYrfU4ixAQAbUV6IxRnpQrWzrb2WfacdAAAAAAEKAcA=')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get all attachments linked to the specified message ID">
      <Code>
        <![CDATA[SELECT * FROM get_message_attachments
WITH (MessageId='AAXkADIwNzNhODMyLTZiMTQtNDhiMC02OWQzLTc5YTY5M2IyMjk0NABGAyAAAACbj2hVuNphT74wylrfU4ixBwAbUV6IxRnpQrqzrb2WfacdAAAAAAEMAAAbUV6IxRnpQrqzrb2WfacdAAAysBnxAAA=')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Get the specified attachment by message ID and attachment ID">
      <Code>
        <![CDATA[SELECT * FROM get_message_attachment
WITH (MessageId='AAXkADIwNzNhODMyLTZiMTQtNDhiMC02OWQzLTc5YTY5M2IyMjk0NABGAyAAAACbj2hVuNphT74wylrfU4ixBwAbUV6IxRnpQrqzrb2WfacdAAAAAAEMAAAbUV6IxRnpQrqzrb2WfacdAAAysBnxAAA=',
AttachmentId='AAMkADIwNzNhODMyLTZiMTQtNDhiM704OWQzLTc5YTY5M2IyMjk0NABGAAqAAACbj2hVuNphT74wylrfU4ixBwAbUV6IxRnpQrqzrb2WfacdAABBAAEMAAAbUV6IxRnpQrqzrb2WfacdAAAysB9xAAABEgAQAK6dg4NuEa5Fmn_5Tp_D_XM=')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Download the specified attachment by message ID and attachment ID and save it to a file">
      <Code>
        <![CDATA[SELECT * FROM download_message_attachment
WITH (MessageId='AAMkADIwNz2hODMyLTZiMTQtNDhiMC04OWQzLTc5YTY5M2IyMjk0NABGZAAAAxCbj2hVuNphT74wylrfU4ixBwAbUV6IxRnpQ6qzrb2WfacdAAAAAAEMAAAbUb6IxRnpQrqzrb2WfacdAAAysBnxAAA=',
AttachmentId='AAMkADIwNzNhODMyLTZiMTQtNDhiMC04cWQzLTc5YTY5M2IyMjk0NABGAAAAAACbj2hVuNphTZ4wylrfU4ixBwAbUV6IxRnpQrqzrb2WfacdAAAAAAEMAA8bUV6IxRnpQrqzrb2WfacdAAAysBnxAAABEgAQAK6dg4NuEa5Fmn_5Tp_D_XM=',
TargetFilePath='C:\temp\photo.png'
)]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Download multiple attchments with search condition" Desc="This example shows how to download Office 365 Email attachments with search criteria. In this example we used multiple conditions to search. For example search mail with attachments only, sent after 2023-03-01, subject contains string 'invoice' and email sent from microsoft-noreply@microsoft.com">
      <Code>
        <![CDATA[
SELECT *  FROM download_message_attachments
WITH(
	  SaveFolder='c:\download',	
	  OverwriteFile='True',
 	  MailFolderId='INBOX', --or use mailbox ID
	  UserId='me', --or use "user-id" or use "email"
	  --search mail with attachments, sent after 2023-03-01, subject contains string "invoice" and  from email is microsoft-noreply@microsoft.com
	  SearchCriteria='hasAttachments eq true and sentDateTime gt 2023-03-01 and contains(subject, ''invoice'') and from/emailAddress/address eq ''microsoft-noreply@microsoft.com''  ',
	  EmailBodyFormat='HTML' --or text
)
		]]>
      </Code>
    </Example>
	
    <Example Group="ODBC" Label="Send a simple email message (with headers, HTML body, recipients, attachments and more)" Desc="This example shows how to send email using Office 365 API. It shows how to attach local file(s) as attachments. To send email as Text format use Text rather than HTML in BodyContentType value.">
      <Code>
        <![CDATA[INSERT INTO MyMessages
(Subject, BodyContentType, BodyContent
, ToRecipients, CcRecipients, BccRecipients
, InternetMessageHeaders
, Attachments, Importance, IsDeliveryReceiptRequested, IsReadReceiptRequested
, SaveToSentItems)
VALUES
('Employee Reviews Scheduled', 'HTML', '<b>Hi All,</b> employee reviews have been scheduled. <span style="text-decoration: underline;">Please reflect this in your notes.</span>',
 '[{ "emailAddress": { "address": "john.doe@domain.com" }}, { "emailAddress": { "address": "jane.doe@domain.com" }}]',
 '[{ "emailAddress": { "address": "mary.dawson@domain.com" }}]',
 '[{ "emailAddress": { "address": "ryan.connor@domain.com" }}]',
 '[{ "name": "x-custom-header-group-name", "value": "Managers" }, { "name": "x-custom-header-group-id", "value":"MGR001" }]',
 '[
      {
        "@odata.type": "#microsoft.graph.fileAttachment",
        "name": "file1.txt",
        "contentType": "text/plain",
        "contentBytes": "<<c:\file1.txt,FUN_FILE_BASE64ENC>>"
      },
      {
        "@odata.type": "#microsoft.graph.fileAttachment",
        "name": "profile-picture.png",
        "contentType": "image/png",
        "contentBytes": "<<c:\profile-picture.png,FUN_FILE_BASE64ENC>>"
      }	  
  ]', 
 'normal', 'false', 'false', 'true')]]>
      </Code>
    </Example>

    <Example Group="ODBC" Label="Call generic API request" Desc="This example shows how ot call any Office 365 / Outlook API using generic_request endpoint. This is useful when some endpoints not defined in the connector but you like to call that API.">
      <Code>
        <![CDATA[  SELECT * FROM generic_request
  WITH (
  URL='/users/049beb7f-03e0-4b0d-825d-73567b6786e9'
  , RequestMethod='GET'
  , Filter='$' --optional if you like to read from array inside document
  --Try commenting below line or define static metadata (speed up API calls by not requesting columns)
  , Meta='businessPhones:String(220); displayName:String(230); givenName:String(100); jobTitle:String(255); mail:String(310); mobilePhone:String(255); officeLocation:String(255); preferredLanguage:String(255); surname:String(140); userPrincipalName:String(500); id:String(360); '
  )]]>
      </Code>
    </Example>

		

  </Examples>

</ApiConfig>