Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Office365 POP3 Login with OAuth2 AuthenticationSee more Office365 ExamplesDemonstrates how to authenticate using OAuth2 using the POP3 protocol with outlook.office365.com. Note: This example requires Chilkat v9.5.0.83 or greater.
integer li_rc oleobject loo_Mailman oleobject loo_JsonToken integer li_Success integer li_NumEmails // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Mailman = create oleobject li_rc = loo_Mailman.ConnectToNewObject("Chilkat_9_5_0.MailMan") if li_rc < 0 then destroy loo_Mailman MessageBox("Error","Connecting to COM object failed") return end if loo_Mailman.MailHost = "outlook.office365.com" loo_Mailman.MailPort = 995 loo_Mailman.PopSsl = 1 // Use your O365 email address here. loo_Mailman.PopUsername = "OFFICE365_EMAIL_ADDRESS" // When using OAuth2 authentication, leave the password empty. loo_Mailman.PopPassword = "" // Load our previously obtained OAuth2 access token. loo_JsonToken = create oleobject li_rc = loo_JsonToken.ConnectToNewObject("Chilkat_9_5_0.JsonObject") li_Success = loo_JsonToken.LoadFile("qa_data/tokens/office365.json") if li_Success = 0 then Write-Debug loo_JsonToken.LastErrorText destroy loo_Mailman destroy loo_JsonToken return end if loo_Mailman.OAuth2AccessToken = loo_JsonToken.StringOf("access_token") // Make the TLS connection to the outlook.office365.com POP3 server. li_Success = loo_Mailman.Pop3Connect() if li_Success <> 1 then Write-Debug loo_Mailman.LastErrorText destroy loo_Mailman destroy loo_JsonToken return end if // Authenticate using XOAUTH2 li_Success = loo_Mailman.Pop3Authenticate() if li_Success <> 1 then Write-Debug loo_Mailman.LastErrorText destroy loo_Mailman destroy loo_JsonToken return end if // Find out how many emails are on the server.. li_NumEmails = loo_Mailman.CheckMail() if li_NumEmails < 0 then Write-Debug loo_Mailman.LastErrorText destroy loo_Mailman destroy loo_JsonToken return end if // Examine the POP3 session log: Write-Debug loo_Mailman.Pop3SessionLog // The POP3 session log will look something like this: // **** Connected to pop.gmail.com:995 // < +OK The Microsoft Exchange POP3 service is ready. [QwBIADIAUABSADEAOABD...YwBvAG0A] // > AUTH XOAUTH2 // < + // > <base64 string in XOAUTH2 format> // < +OK User successfully authenticated. // > STAT // < +OK 3 375302 // End the POP3 session and close the connection to the GMail server. li_Success = loo_Mailman.Pop3EndSession() if li_Success <> 1 then Write-Debug loo_Mailman.LastErrorText destroy loo_Mailman destroy loo_JsonToken return end if Write-Debug "Finished." destroy loo_Mailman destroy loo_JsonToken |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.