Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

MBS FileMaker Plugin Example Databases

Office 365 oAuth SMTP

All examples are included with download of MBS FileMaker Plugin.

Office 365 oAuth SMTP.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts8
Value Lists0
Custom Functions0
Custom Menus24
File Options
Default custom menu set[Standard FileMaker Menus]
When opening file
Minimum allowed version12.0
Login usingAccount Name; Account= Admin
Allow user to save passwordOff
Require iOS passcodeOff
Switch to layoutOff
Hide all toolbarsOff
Script triggers
OnFirstWindowOpenOff
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
Office 365 oAuth SMTP
21 fields defined, 1 record
Office 365 oAuth SMTP

Fields

Table Name: Office 365 oAuth SMTP - 21 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
PrimaryKeyNormal, TextAuto-Enter: Validation:
  • Only during data entry
  • Not empty
  • Unique
  • Strict validation
Storage:
  • Repetitions: 1
  • Indexing: Minimal
  • Automatically create indexes as needed
  • Index Language: Unicode Raw
Unique identifier of each record in this table
          CreationTimestampNormal, TimestampAuto-Enter:
          • Creation timestamp
          Validation:
          • Only during data entry
          • Strict data type: 4 digit year
          • Not empty
          • Strict validation
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
          Date and time each record was created
                  CreatedByNormal, TextAuto-Enter:
                  • Creation account name
                  Validation:
                  • Only during data entry
                  • Not empty
                  • Strict validation
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                  Account name of the user who created each record
                          ModificationTimestampNormal, TimestampAuto-Enter:
                          • Modification timestamp
                          Validation:
                          • Only during data entry
                          • Strict data type: 4 digit year
                          • Not empty
                          • Strict validation
                          Storage:
                          • Repetitions: 1
                          • Indexing: None
                          • Automatically create indexes as needed
                          • Index Language: German
                          Date and time each record was last modified
                                  ModifiedByNormal, TextAuto-Enter:
                                  • Modification account name
                                  Validation:
                                  • Only during data entry
                                  • Not empty
                                  • Strict validation
                                  Storage:
                                  • Repetitions: 1
                                  • Indexing: None
                                  • Automatically create indexes as needed
                                  • Index Language: German
                                  Account name of the user who last modified each record
                                          DebugNormal, TextAuto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1
                                          • Indexing: None
                                          • Automatically create indexes as needed
                                          • Index Language: German
                                              URLNormal, TextAuto-Enter:
                                              • Allow editing
                                              Validation:
                                              • Only during data entry
                                              Storage:
                                              • Repetitions: 1
                                              • Indexing: None
                                              • Automatically create indexes as needed
                                              • Index Language: German
                                                  CURL DebugNormal, TextAuto-Enter:
                                                  • Allow editing
                                                  Validation:
                                                  • Only during data entry
                                                  Storage:
                                                  • Repetitions: 1
                                                  • Indexing: None
                                                  • Automatically create indexes as needed
                                                  • Index Language: German
                                                      CURL ResultNormal, TextAuto-Enter:
                                                      • Allow editing
                                                      Validation:
                                                      • Only during data entry
                                                      Storage:
                                                      • Repetitions: 1
                                                      • Indexing: None
                                                      • Automatically create indexes as needed
                                                      • Index Language: German
                                                          access_tokenNormal, TextAuto-Enter:
                                                          • Allow editing
                                                          Validation:
                                                          • Only during data entry
                                                          Storage:
                                                          • Repetitions: 1
                                                          • Indexing: None
                                                          • Automatically create indexes as needed
                                                          • Index Language: German
                                                              AnswerNormal, TextAuto-Enter:
                                                              • Allow editing
                                                              Validation:
                                                              • Only during data entry
                                                              Storage:
                                                              • Repetitions: 1
                                                              • Indexing: None
                                                              • Automatically create indexes as needed
                                                              • Index Language: German
                                                                  ClientIDNormal, TextAuto-Enter:
                                                                  • Allow editing
                                                                  Validation:
                                                                  • Only during data entry
                                                                  Storage:
                                                                  • Repetitions: 1
                                                                  • Indexing: None
                                                                  • Automatically create indexes as needed
                                                                  • Index Language: German
                                                                      ClientSecretNormal, TextAuto-Enter:
                                                                      • Allow editing
                                                                      Validation:
                                                                      • Only during data entry
                                                                      Storage:
                                                                      • Repetitions: 1
                                                                      • Indexing: None
                                                                      • Automatically create indexes as needed
                                                                      • Index Language: German
                                                                          TenantIDNormal, TextAuto-Enter:
                                                                          • Allow editing
                                                                          Validation:
                                                                          • Only during data entry
                                                                          Storage:
                                                                          • Repetitions: 1
                                                                          • Indexing: None
                                                                          • Automatically create indexes as needed
                                                                          • Index Language: German
                                                                              From EmailNormal, TextAuto-Enter:
                                                                              • Allow editing
                                                                              Validation:
                                                                              • Only during data entry
                                                                              Storage:
                                                                              • Repetitions: 1
                                                                              • Indexing: None
                                                                              • Automatically create indexes as needed
                                                                              • Index Language: German
                                                                                  To EmailNormal, TextAuto-Enter:
                                                                                  • Allow editing
                                                                                  Validation:
                                                                                  • Only during data entry
                                                                                  Storage:
                                                                                  • Repetitions: 1
                                                                                  • Indexing: None
                                                                                  • Automatically create indexes as needed
                                                                                  • Index Language: German
                                                                                      From NameNormal, TextAuto-Enter:
                                                                                      • Allow editing
                                                                                      Validation:
                                                                                      • Only during data entry
                                                                                      Storage:
                                                                                      • Repetitions: 1
                                                                                      • Indexing: None
                                                                                      • Automatically create indexes as needed
                                                                                      • Index Language: German
                                                                                          To NameNormal, TextAuto-Enter:
                                                                                          • Allow editing
                                                                                          Validation:
                                                                                          • Only during data entry
                                                                                          Storage:
                                                                                          • Repetitions: 1
                                                                                          • Indexing: None
                                                                                          • Automatically create indexes as needed
                                                                                          • Index Language: German
                                                                                              SubjectNormal, TextAuto-Enter:
                                                                                              • Allow editing
                                                                                              Validation:
                                                                                              • Only during data entry
                                                                                              Storage:
                                                                                              • Repetitions: 1
                                                                                              • Indexing: None
                                                                                              • Automatically create indexes as needed
                                                                                              • Index Language: German
                                                                                                  Email TextNormal, TextAuto-Enter:
                                                                                                  • Allow editing
                                                                                                  Validation:
                                                                                                  • Only during data entry
                                                                                                  Storage:
                                                                                                  • Repetitions: 1
                                                                                                  • Indexing: None
                                                                                                  • Automatically create indexes as needed
                                                                                                  • Index Language: German
                                                                                                      refresh_tokenNormal, TextAuto-Enter:
                                                                                                      • Allow editing
                                                                                                      Validation:
                                                                                                      • Only during data entry
                                                                                                      Storage:
                                                                                                      • Repetitions: 1
                                                                                                      • Indexing: None
                                                                                                      • Automatically create indexes as needed
                                                                                                      • Index Language: German

                                                                                                          Layout Objects: Office 365 oAuth SMTP

                                                                                                          Regular Fields

                                                                                                          Field Name: Office 365 oAuth SMTP::Debug
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 89 pt
                                                                                                          • Left: 893 pt
                                                                                                          • Bottom: 174 pt
                                                                                                          • Right: 1146 pt
                                                                                                          • Anchoring: Left and Right, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::URL
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 182 pt
                                                                                                          • Left: 893 pt
                                                                                                          • Bottom: 267 pt
                                                                                                          • Right: 1146 pt
                                                                                                          • Anchoring: Left and Right, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::CURL Debug
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 275 pt
                                                                                                          • Left: 893 pt
                                                                                                          • Bottom: 360 pt
                                                                                                          • Right: 1146 pt
                                                                                                          • Anchoring: Left and Right, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::CURL Result
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 368 pt
                                                                                                          • Left: 893 pt
                                                                                                          • Bottom: 453 pt
                                                                                                          • Right: 1146 pt
                                                                                                          • Anchoring: Left and Right, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::access_token
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 554 pt
                                                                                                          • Left: 893 pt
                                                                                                          • Bottom: 639 pt
                                                                                                          • Right: 1146 pt
                                                                                                          • Anchoring: Left and Right, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::Answer
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 461 pt
                                                                                                          • Left: 893 pt
                                                                                                          • Bottom: 546 pt
                                                                                                          • Right: 1146 pt
                                                                                                          • Anchoring: Left and Right, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::ClientID
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 726 pt
                                                                                                          • Left: 138 pt
                                                                                                          • Bottom: 757 pt
                                                                                                          • Right: 391 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::ClientSecret
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 761 pt
                                                                                                          • Left: 138 pt
                                                                                                          • Bottom: 792 pt
                                                                                                          • Right: 391 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::TenantID
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 796 pt
                                                                                                          • Left: 138 pt
                                                                                                          • Bottom: 827 pt
                                                                                                          • Right: 391 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::From Email
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 726 pt
                                                                                                          • Left: 506 pt
                                                                                                          • Bottom: 757 pt
                                                                                                          • Right: 759 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::To Email
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 796 pt
                                                                                                          • Left: 506 pt
                                                                                                          • Bottom: 827 pt
                                                                                                          • Right: 759 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::From Name
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 761 pt
                                                                                                          • Left: 506 pt
                                                                                                          • Bottom: 792 pt
                                                                                                          • Right: 759 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::To Name
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 831 pt
                                                                                                          • Left: 506 pt
                                                                                                          • Bottom: 862 pt
                                                                                                          • Right: 759 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::Subject
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 726 pt
                                                                                                          • Left: 866 pt
                                                                                                          • Bottom: 757 pt
                                                                                                          • Right: 1119 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::Email Text
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 761 pt
                                                                                                          • Left: 866 pt
                                                                                                          • Bottom: 862 pt
                                                                                                          • Right: 1119 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Field Name: Office 365 oAuth SMTP::refresh_token
                                                                                                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                                                                          • Top: 866 pt
                                                                                                          • Left: 138 pt
                                                                                                          • Bottom: 936 pt
                                                                                                          • Right: 759 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          Field Format:
                                                                                                          • Edit Box
                                                                                                          Field Behavior:
                                                                                                          • Allow field to be entered: In Find mode, In Browse mode
                                                                                                          • Touch keyboard type: Default for Data Type
                                                                                                          • Go to next field using: Tab key
                                                                                                          Yes

                                                                                                          Buttons

                                                                                                          Button PropertiesCoordinatesScript/Script Step
                                                                                                            Type:
                                                                                                          • Text: Open Scripts
                                                                                                          • Top: 17 pt
                                                                                                          • Left: 772 pt
                                                                                                          • Bottom: 48 pt
                                                                                                          • Right: 959 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          Open Script Workspace

                                                                                                          Web Viewer Controls

                                                                                                          Web Viewer Control PropertiesCoordinatesWeb Address
                                                                                                            Additional Properties:
                                                                                                          • Allow interaction with web viewer content
                                                                                                          • Display progress bar
                                                                                                          • Display status messages
                                                                                                          • Top: 89 pt
                                                                                                          • Left: 10 pt
                                                                                                          • Bottom: 722 pt
                                                                                                          • Right: 759 pt
                                                                                                          • Anchoring: Left, Top
                                                                                                          "about:blank"

                                                                                                          Script Hierarchy

                                                                                                          Start Authentication
                                                                                                          WebHookReceived
                                                                                                          Query Token
                                                                                                          Extract Access Token
                                                                                                          Send Email
                                                                                                          Clear
                                                                                                          Logout from WebViewer
                                                                                                          Refresh Token

                                                                                                          Next Script: [WebHookReceived]
                                                                                                          Script NameStart Authentication
                                                                                                          Run script with full access privilegesOff
                                                                                                          Include In MenuYes
                                                                                                          Layouts that use this script
                                                                                                            Scripts that use this script
                                                                                                              Script Definition
                                                                                                              Script Steps
                                                                                                              • #Start a web view for the callback
                                                                                                              • If [ IsEmpty ( $$WebHooks ) ]
                                                                                                              • #setup callback
                                                                                                              • Set Variable [ $$WebHooks; Value:MBS("WebHook.Create") ]
                                                                                                              • Set Variable [ $r; Value:MBS("WebHook.Listen"; $$WebHooks; 9999) ]
                                                                                                              • Set Variable [ $r; Value:MBS("WebHook.SetScript"; $$WebHooks; Get(FileName); "WebHookReceived") ]
                                                                                                              • Set Variable [ $text; Value:"<html><p>Request arrived.</p></html>" ]
                                                                                                              • Set Variable [ $text; Value:"HTTP/1.1 200 OK¶Server: MyServer 1.0¶Connection: close¶Content-Type: text/html¶Content-Length: 36¶¶" & $text ]
                                                                                                              • Set Variable [ $text; Value:MBS( "Text.ReplaceNewline"; $Text; 3 ) ]
                                                                                                              • Set Variable [ $r; Value:MBS("WebHook.SetAutoAnswer"; $$Webhooks; $text; "UTF-8") ]
                                                                                                              • End If
                                                                                                              • #Now load URL in browser to have user login:
                                                                                                              • #Please signup your own Azure app with the redirect URI below and the client secret.
                                                                                                              • #see https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app
                                                                                                              • Set Variable [ $clientID; Value:Trim(Office 365 oAuth SMTP::ClientID) ]
                                                                                                              • Set Variable [ $TenantID; Value:Trim(Office 365 oAuth SMTP::TenantID) ]
                                                                                                              • Set Variable [ $redirectURI; Value:"http://localhost:9999/" ]
                                                                                                              • Set Variable [ $redirectURI; Value:MBS("Text.EncodeURLComponent"; $redirectURI; "UTF-8") ]
                                                                                                              • Set Variable [ $scope; Value:"offline_access https://outlook.office365.com/SMTP.Send https://outlook.office365.com/IMAP.AccessAsUser.All" // "openid profile offline_access https://outlook.office365.com/POP.AccessAsUser.All https://outlook.office365.com/IMAP.AccessAsUser.All" ]
                                                                                                              • Set Variable [ $scope; Value:MBS("Text.EncodeURLComponent"; $scope; "UTF-8") ]
                                                                                                              • Set Variable [ $URL; Value:"https://login.microsoftonline.com/" & $TenantID & "/oauth2/v2.0/authorize?response_type=code&scope=" & $scope & "&redirect_uri=" & $redirectURI & "&client_id=" & $clientID & "&state=test" ]
                                                                                                              • #let web viewer be Safari
                                                                                                              • Set Variable [ $r; Value:MBS("WebView.SetCustomUserAgent"; "web"; "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15") ]
                                                                                                              • #Load the URL
                                                                                                              • Set Variable [ $r; Value:MBS( "WebView.LoadURL"; "web"; $URL) ]
                                                                                                              • #show for debugging
                                                                                                              • Set Field [ Office 365 oAuth SMTP::URL; $URL ]
                                                                                                              Fields used in this script
                                                                                                              Scripts used in this script
                                                                                                                Layouts used in this script
                                                                                                                  Tables used in this script
                                                                                                                  Table occurrences used by this script
                                                                                                                  Custom Functions used by this script
                                                                                                                    Custom menu set used by this script

                                                                                                                      Previous Script: [Start Authentication]Next Script: [Query Token]
                                                                                                                      Script NameWebHookReceived
                                                                                                                      Run script with full access privilegesOff
                                                                                                                      Include In MenuNo
                                                                                                                      Layouts that use this script
                                                                                                                        Scripts that use this script
                                                                                                                          Script Definition
                                                                                                                          Script Steps
                                                                                                                          • Set Variable [ $WebRequest; Value:Get(ScriptParameter) ]
                                                                                                                          • #we got the answer
                                                                                                                          • Set Variable [ $URLComponents; Value:MBS( "WebRequest.URLComponents"; $WebRequest ) ]
                                                                                                                          • If [ Position ( JSONGetElement ( $URLComponents ; "RelativeURL" ); "favicon.ico"; 1; 1 ) > 0 ]
                                                                                                                          • #ignore query for favicon
                                                                                                                          • Exit Script [ ]
                                                                                                                          • End If
                                                                                                                          • Set Field [ Office 365 oAuth SMTP::Answer; $URLComponents ]
                                                                                                                          • #and show full request for debugging
                                                                                                                          • Set Variable [ $Text; Value:MBS( "Text.ReplaceNewline"; MBS("WebRequest.GetRawData"; $WebRequest; "UTF-8"); 1) ]
                                                                                                                          • Set Field [ Office 365 oAuth SMTP::Debug; $Text ]
                                                                                                                          • #free the webhook and request
                                                                                                                          • Set Variable [ $r; Value:MBS("WebRequest.Release"; $WebRequest) ]
                                                                                                                          • Set Variable [ $r; Value:MBS("WebHook.Release"; $$WebHooks) ]
                                                                                                                          • Set Variable [ $$WebHooks; Value:"" ]
                                                                                                                          • #clear web viewer
                                                                                                                          • Set Variable [ $r; Value:MBS( "WebView.LoadURL"; "web"; "about:blank") ]
                                                                                                                          • #Now continue with query token
                                                                                                                          • Perform Script [ “Query Token” ]
                                                                                                                          Fields used in this script
                                                                                                                          Scripts used in this script
                                                                                                                          Layouts used in this script
                                                                                                                            Tables used in this script
                                                                                                                            Table occurrences used by this script
                                                                                                                            Custom Functions used by this script
                                                                                                                              Custom menu set used by this script

                                                                                                                                Previous Script: [WebHookReceived]Next Script: [Extract Access Token]
                                                                                                                                Script NameQuery Token
                                                                                                                                Run script with full access privilegesOff
                                                                                                                                Include In MenuNo
                                                                                                                                Layouts that use this script
                                                                                                                                  Scripts that use this script
                                                                                                                                  Script Definition
                                                                                                                                  Script Steps
                                                                                                                                  • Set Variable [ $URLComponents; Value:Office 365 oAuth SMTP::Answer ]
                                                                                                                                  • Set Variable [ $Parameters; Value:JSONGetElement ( $URLComponents ; "Parameters" ) ]
                                                                                                                                  • Set Variable [ $code; Value:JSONGetElement ( $Parameters ; "code" ) ]
                                                                                                                                  • Set Variable [ $state; Value:JSONGetElement ( $Parameters ; "state" ) ]
                                                                                                                                  • Set Variable [ $session_state; Value:JSONGetElement ( $Parameters ; "session_state" ) ]
                                                                                                                                  • #if we got a code, we continue to query the access code
                                                                                                                                  • If [ Length ( $code ) > 0 ]
                                                                                                                                  • Set Variable [ $TenantID; Value:Trim(Office 365 oAuth SMTP::TenantID) ]
                                                                                                                                  • Set Variable [ $clientID; Value:Trim ( Office 365 oAuth SMTP::ClientID ) ]
                                                                                                                                  • Set Variable [ $clientSecret; Value:Trim(Office 365 oAuth SMTP::ClientSecret) ]
                                                                                                                                  • Set Variable [ $URL; Value:"https://login.microsoftonline.com/" & $TenantID & "/oauth2/v2.0/token" ]
                                                                                                                                  • Set Variable [ $redirectURI; Value:MBS("Text.EncodeURLComponent"; "http://localhost:9999/"; "UTF-8") ]
                                                                                                                                  • Set Variable [ $Data; Value:"code=" & $code & "&client_id=" & $clientID & "&client_secret=" & $clientSecret & "&grant_type=authorization_code" & "&redirect_uri=" & $redirectURI ]
                                                                                                                                  • Set Variable [ $curl; Value:MBS("CURL.New") ]
                                                                                                                                  • Set Variable [ $result; Value:MBS("CURL.SetOptionURL"; $curl; $URL) ]
                                                                                                                                  • Set Variable [ $result; Value:MBS("CURL.SetOptionPostFields"; $curl; $Data; "UTF-8") ]
                                                                                                                                  • Set Variable [ $result; Value:MBS("CURL.SetOptionHTTPHeader"; $curl; "application/x-www-form-urlencoded") ]
                                                                                                                                  • Set Variable [ $result; Value:MBS("CURL.Perform"; $curl) ]
                                                                                                                                  • #Pick Result
                                                                                                                                  • Set Variable [ $code; Value:MBS( "CURL.GetResponseCode"; $curl ) ]
                                                                                                                                  • If [ $result = "OK" and $code = 200 ]
                                                                                                                                  • Set Variable [ $resultText; Value:MBS("CURL.GetResultAsText"; $curl) ]
                                                                                                                                  • Set Variable [ $debugText; Value:MBS("CURL.GetDebugAsText"; $curl) ]
                                                                                                                                  • Set Field [ Office 365 oAuth SMTP::CURL Debug; $DebugText ]
                                                                                                                                  • Set Field [ Office 365 oAuth SMTP::CURL Result; $resultText ]
                                                                                                                                  • Perform Script [ “Extract Access Token” ]
                                                                                                                                  • Else
                                                                                                                                  • Show Custom Dialog [ Title: "SMTP"; Message: "Failed to query token."; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                  • End If
                                                                                                                                  • Set Variable [ $result; Value:MBS("CURL.Cleanup"; $curl) ]
                                                                                                                                  • End If
                                                                                                                                  Fields used in this script
                                                                                                                                  Scripts used in this script
                                                                                                                                  Layouts used in this script
                                                                                                                                    Tables used in this script
                                                                                                                                    Table occurrences used by this script
                                                                                                                                    Custom Functions used by this script
                                                                                                                                      Custom menu set used by this script

                                                                                                                                        Previous Script: [Query Token]Next Script: [Send Email]
                                                                                                                                        Script NameExtract Access Token
                                                                                                                                        Run script with full access privilegesOff
                                                                                                                                        Include In MenuNo
                                                                                                                                        Layouts that use this script
                                                                                                                                          Scripts that use this script
                                                                                                                                          Script Definition
                                                                                                                                          Script Steps
                                                                                                                                          • Set Variable [ $Result; Value:Office 365 oAuth SMTP::CURL Result ]
                                                                                                                                          • #get access token
                                                                                                                                          • Set Variable [ $token_type; Value:JSONGetElement ( $Result ; "token_type" ) ]
                                                                                                                                          • Set Variable [ $scope; Value:JSONGetElement ( $Result ; "scope" ) ]
                                                                                                                                          • Set Variable [ $expires_in; Value:JSONGetElement ( $Result ; "expires_in" ) ]
                                                                                                                                          • Set Variable [ $ext_expires_in; Value:JSONGetElement ( $Result ; "ext_expires_in" ) ]
                                                                                                                                          • Set Variable [ $access_token; Value:JSONGetElement ( $Result ; "access_token" ) ]
                                                                                                                                          • Set Variable [ $refresh_token; Value:JSONGetElement ( $Result ; "refresh_token" ) ]
                                                                                                                                          • If [ Length ( $access_token ) > 0 ]
                                                                                                                                          • Set Field [ Office 365 oAuth SMTP::access_token; $access_token ]
                                                                                                                                          • If [ Length ( $refresh_token ) > 0 ]
                                                                                                                                          • #we only get one, if offline_access scope is set
                                                                                                                                          • Set Field [ Office 365 oAuth SMTP::refresh_token; $refresh_token ]
                                                                                                                                          • End If
                                                                                                                                          • Show Custom Dialog [ Title: "Got token!"; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                          • End If
                                                                                                                                          Fields used in this script
                                                                                                                                          Scripts used in this script
                                                                                                                                            Layouts used in this script
                                                                                                                                              Tables used in this script
                                                                                                                                              Table occurrences used by this script
                                                                                                                                              Custom Functions used by this script
                                                                                                                                                Custom menu set used by this script

                                                                                                                                                  Previous Script: [Extract Access Token]Next Script: [Clear]
                                                                                                                                                  Script NameSend Email
                                                                                                                                                  Run script with full access privilegesOff
                                                                                                                                                  Include In MenuYes
                                                                                                                                                  Layouts that use this script
                                                                                                                                                    Scripts that use this script
                                                                                                                                                      Script Definition
                                                                                                                                                      Script Steps
                                                                                                                                                      • #create email
                                                                                                                                                      • Set Variable [ $EmailID; Value:MBS("SendMail.CreateEmail") ]
                                                                                                                                                      • Set Variable [ $r; Value:MBS("SendMail.SetFrom"; $EmailID; Trim(Office 365 oAuth SMTP::From Email); Trim(Office 365 oAuth SMTP::From Name)) ]
                                                                                                                                                      • Set Variable [ $r; Value:MBS("SendMail.SetPlainText"; $EmailID; Office 365 oAuth SMTP::Email Text) ]
                                                                                                                                                      • Set Variable [ $r; Value:MBS("SendMail.SetSubject"; $EmailID; Office 365 oAuth SMTP::Subject) ]
                                                                                                                                                      • Set Variable [ $r; Value:MBS("SendMail.SetSMTPServer"; $EmailID; "smtp.office365.com") ]
                                                                                                                                                      • Set Variable [ $r; Value:MBS("SendMail.SetSMTPUsername"; $EmailID; Trim(Office 365 oAuth SMTP::From Email)) ]
                                                                                                                                                      • Set Variable [ $r; Value:MBS("SendMail.AddTO"; $EmailID; Trim (Office 365 oAuth SMTP::To Email); Trim (Office 365 oAuth SMTP::To Name)) ]
                                                                                                                                                      • Set Variable [ $curl; Value:MBS("CURL.New") ]
                                                                                                                                                      • Set Variable [ $r; Value:MBS("SendMail.PrepareCURL"; $EmailID; $curl) ]
                                                                                                                                                      • #Maybe use alternative SMTP port?
                                                                                                                                                      • Set Variable [ $r; Value:MBS("CURL.SetOptionPort"; $curl; 587) ]
                                                                                                                                                      • #This turns TLS on and requires connection to be encrypted
                                                                                                                                                      • Set Variable [ $r; Value:MBS("CURL.SetOptionUseSSL"; $curl; 3) ]
                                                                                                                                                      • #force TLS v1.2
                                                                                                                                                      • Set Variable [ $r; Value:MBS("CURL.SetOptionSSLVersion"; $curl; 6) ]
                                                                                                                                                      • #This disables certificate verification, so we accept any:
                                                                                                                                                      • Set Variable [ $r; Value:MBS("CURL.SetOptionSSLVerifyHost"; $curl; 0) ]
                                                                                                                                                      • Set Variable [ $r; Value:MBS("CURL.SetOptionSSLVerifyPeer"; $curl; 0) ]
                                                                                                                                                      • #put in token
                                                                                                                                                      • Set Variable [ $r; Value:MBS("CURL.SetOptionXOAuth2Bearer"; $curl; Office 365 oAuth SMTP::access_token) ]
                                                                                                                                                      • #Better with certificates if you have some:
                                                                                                                                                      • // Set Variable [ $r; Value:MBS( "CURL.SetOptionCAInfo"; $curl; "/Library/FileMaker Server/certificates.pem") ]
                                                                                                                                                      • // Set Variable [ $r; Value:MBS("CURL.SetOptionSSLVerifyHost"; $curl; 2) ]
                                                                                                                                                      • // Set Variable [ $r; Value:MBS("CURL.SetOptionSSLVerifyPeer"; $curl; 1) ]
                                                                                                                                                      • #Run the transfer
                                                                                                                                                      • Set Variable [ $r; Value:MBS("CURL.Perform"; $curl) ]
                                                                                                                                                      • #get debug messages
                                                                                                                                                      • Set Field [ Office 365 oAuth SMTP::CURL Debug; MBS("CURL.GetDebugAsText"; $curl; "UTF-8") ]
                                                                                                                                                      • Set Variable [ $r; Value:MBS("CURL.Release"; $curl) ]
                                                                                                                                                      • # Cleanup
                                                                                                                                                      • Set Variable [ $r; Value:MBS("SendMail.Release"; $EmailID) ]
                                                                                                                                                      Fields used in this script
                                                                                                                                                      Scripts used in this script
                                                                                                                                                        Layouts used in this script
                                                                                                                                                          Tables used in this script
                                                                                                                                                          Table occurrences used by this script
                                                                                                                                                          Custom Functions used by this script
                                                                                                                                                            Custom menu set used by this script

                                                                                                                                                              Previous Script: [Send Email]Next Script: [Logout from WebViewer]
                                                                                                                                                              Script NameClear
                                                                                                                                                              Run script with full access privilegesOff
                                                                                                                                                              Include In MenuYes
                                                                                                                                                              Layouts that use this script
                                                                                                                                                                Scripts that use this script
                                                                                                                                                                  Script Definition
                                                                                                                                                                  Script Steps
                                                                                                                                                                  • Set Field [ Office 365 oAuth SMTP::Debug; "" ]
                                                                                                                                                                  • Set Field [ Office 365 oAuth SMTP::URL; "" ]
                                                                                                                                                                  • Set Field [ Office 365 oAuth SMTP::CURL Debug; "" ]
                                                                                                                                                                  • Set Field [ Office 365 oAuth SMTP::CURL Result; "" ]
                                                                                                                                                                  • Set Field [ Office 365 oAuth SMTP::access_token; "" ]
                                                                                                                                                                  • Set Field [ Office 365 oAuth SMTP::Answer; "" ]
                                                                                                                                                                  Fields used in this script
                                                                                                                                                                  Scripts used in this script
                                                                                                                                                                    Layouts used in this script
                                                                                                                                                                      Tables used in this script
                                                                                                                                                                      Table occurrences used by this script
                                                                                                                                                                      Custom Functions used by this script
                                                                                                                                                                        Custom menu set used by this script

                                                                                                                                                                          Previous Script: [Clear]Next Script: [Refresh Token]
                                                                                                                                                                          Script NameLogout from WebViewer
                                                                                                                                                                          Run script with full access privilegesOff
                                                                                                                                                                          Include In MenuYes
                                                                                                                                                                          Layouts that use this script
                                                                                                                                                                            Scripts that use this script
                                                                                                                                                                              Script Definition
                                                                                                                                                                              Script Steps
                                                                                                                                                                              • #In case you are logged in for the webviewer and you can't login with a new account, use this script to logout
                                                                                                                                                                              • #let web viewer be Safari
                                                                                                                                                                              • Set Variable [ $r; Value:MBS("WebView.SetCustomUserAgent"; "web"; "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15") ]
                                                                                                                                                                              • #Load the URL
                                                                                                                                                                              • Set Variable [ $URL; Value:"https://login.microsoftonline.com/common/oauth2/logout" ]
                                                                                                                                                                              • Set Variable [ $r; Value:MBS( "WebView.LoadURL"; "web"; $URL) ]
                                                                                                                                                                              • #show for debugging
                                                                                                                                                                              • Set Field [ Office 365 oAuth SMTP::URL; $URL ]
                                                                                                                                                                              Fields used in this script
                                                                                                                                                                              Scripts used in this script
                                                                                                                                                                                Layouts used in this script
                                                                                                                                                                                  Tables used in this script
                                                                                                                                                                                  Table occurrences used by this script
                                                                                                                                                                                  Custom Functions used by this script
                                                                                                                                                                                    Custom menu set used by this script

                                                                                                                                                                                      Previous Script: [Logout from WebViewer]
                                                                                                                                                                                      Script NameRefresh Token
                                                                                                                                                                                      Run script with full access privilegesOff
                                                                                                                                                                                      Include In MenuYes
                                                                                                                                                                                      Layouts that use this script
                                                                                                                                                                                        Scripts that use this script
                                                                                                                                                                                          Script Definition
                                                                                                                                                                                          Script Steps
                                                                                                                                                                                          • If [ Length ( Office 365 oAuth SMTP::refresh_token ) = 0 ]
                                                                                                                                                                                          • Show Custom Dialog [ Title: "Can't refresh the token."; Message: "Please get a token first!"; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                          • Exit Script [ ]
                                                                                                                                                                                          • End If
                                                                                                                                                                                          • Set Variable [ $TenantID; Value:Trim(Office 365 oAuth SMTP::TenantID) ]
                                                                                                                                                                                          • Set Variable [ $clientID; Value:Trim ( Office 365 oAuth SMTP::ClientID ) ]
                                                                                                                                                                                          • Set Variable [ $clientSecret; Value:Trim(Office 365 oAuth SMTP::ClientSecret) ]
                                                                                                                                                                                          • Set Variable [ $URL; Value:"https://login.microsoftonline.com/" & $TenantID & "/oauth2/v2.0/token" ]
                                                                                                                                                                                          • Set Variable [ $redirectURI; Value:MBS("Text.EncodeURLComponent"; "http://localhost:9999/"; "UTF-8") ]
                                                                                                                                                                                          • Set Variable [ $scope; Value:"offline_access https://outlook.office365.com/SMTP.Send https://outlook.office365.com/IMAP.AccessAsUser.All" // same as before! ]
                                                                                                                                                                                          • Set Variable [ $Data; Value:"client_id=" & $clientID & "&scope=" & $scope & "&refresh_token=" & Office 365 oAuth SMTP::refresh_token & "&client_secret=" & $clientSecret & "&grant_type=refresh_token" & "&redirect_uri=" & $redirectURI ]
                                                                                                                                                                                          • Set Variable [ $curl; Value:MBS("CURL.New") ]
                                                                                                                                                                                          • Set Variable [ $result; Value:MBS("CURL.SetOptionURL"; $curl; $URL) ]
                                                                                                                                                                                          • Set Variable [ $result; Value:MBS("CURL.SetOptionPostFields"; $curl; $Data; "UTF-8") ]
                                                                                                                                                                                          • Set Variable [ $result; Value:MBS("CURL.SetOptionHTTPHeader"; $curl; "application/x-www-form-urlencoded") ]
                                                                                                                                                                                          • Set Variable [ $result; Value:MBS("CURL.Perform"; $curl) ]
                                                                                                                                                                                          • #Pick Result
                                                                                                                                                                                          • Set Variable [ $code; Value:MBS( "CURL.GetResponseCode"; $curl ) ]
                                                                                                                                                                                          • If [ $result = "OK" and $code = 200 ]
                                                                                                                                                                                          • Set Variable [ $resultText; Value:MBS("CURL.GetResultAsText"; $curl) ]
                                                                                                                                                                                          • Set Variable [ $debugText; Value:MBS("CURL.GetDebugAsText"; $curl) ]
                                                                                                                                                                                          • Set Field [ Office 365 oAuth SMTP::CURL Debug; $DebugText ]
                                                                                                                                                                                          • Set Field [ Office 365 oAuth SMTP::CURL Result; $resultText ]
                                                                                                                                                                                          • Perform Script [ “Extract Access Token” ]
                                                                                                                                                                                          • Else
                                                                                                                                                                                          • Show Custom Dialog [ Title: "SMTP"; Message: "Failed to query token."; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                          • End If
                                                                                                                                                                                          • Set Variable [ $result; Value:MBS("CURL.Cleanup"; $curl) ]
                                                                                                                                                                                          Fields used in this script
                                                                                                                                                                                          Scripts used in this script
                                                                                                                                                                                          Layouts used in this script
                                                                                                                                                                                            Tables used in this script
                                                                                                                                                                                            Table occurrences used by this script
                                                                                                                                                                                            Custom Functions used by this script
                                                                                                                                                                                              Custom menu set used by this script

                                                                                                                                                                                                Download example: Office 365 oAuth SMTP

                                                                                                                                                                                                Used functions: