0

My IMAP code to check emails at Office 365 just stopped working last fall (client didn't notice until just recently).

This is my code. It dies at the login:

  Chilkat.Global glob = new Chilkat.Global();
  var success = glob.UnlockBundle("MyUnlockCode");

  if (success != true)
  {
      log.LogError("ProcessLatestEmails. Error unlocking component: " + imap.LastErrorText);
      return false;
  }

  // To use a secure TLS/SSL connection, set the Ssl property and the port:
  imap.Ssl = UseSSL;
  imap.Port = Port;
  success = imap.Connect(Server);

  if (success != true)
  {
      log.LogError("ProcessLatestEmails. Error connecting to server: " + imap.LastErrorText);
      return false;
  }

  success = imap.Login(UserName, Password);

  if (success != true)
  {
      log.LogError("ProcessLatestEmails. Error logging in: " + imap.LastErrorText);
      imap.Disconnect();
      imap.Dispose();
      return false;
  }

This is error that is returned:

ProcessLatestEmails. Error logging in: ChilkatLog:

Login:
DllDate: Dec 29 2022
ChilkatVersion: 9.5.0.93
UnlockPrefix: UnlockCodeWasHere
Architecture: Little Endian; 64-bit
VerboseLogging: 0
imapServer: outlook.office365.com
loginX(2797ms):
login: adam@clientdomain.com
greeting: * OK The Microsoft Exchange IMAP4 service is ready. [QgBZAEEAUABSADIAMgBvAGQALgBv...AHUAdABsAG8AbwBrAC4AYwBvAG0A]

authenticateLogin(2797ms):
loginImap(2797ms):
ConnectionType: SSL/TLS
ImapCmdSent: aaab LOGIN "adam@clientdomain.com"
getCompleteResponse(2797ms):
ImapCmdResp: aaab NO LOGIN failed.
--getCompleteResponse
--loginImap
isOK: serverResponse: aaab NO LOGIN failed.
--isOK
--authenticateLogin
--loginX
Failed.
--Login
--ChilkatLog

I verified that IMAP is still enabled for all accounts. I also verified that the passwords are correct.

Is this a deprecated pattern and I need to figure out OAuth or can I get it working.

I am using ChilkatDnCore31 v9.5.0.93 and running this is an Azure Functions instance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Brad Mathews
  • 1,567
  • 2
  • 23
  • 45

1 Answers1

0

See https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/deprecation-of-basic-authentication-exchange-online

also see https://techcommunity.microsoft.com/t5/exchange-team-blog/basic-authentication-deprecation-in-exchange-online-september/ba-p/3609437

Chilkat published more information and examples for OAuth2 w/ Office365 and MS Exchange. The blog post that summarizes and serves as a good starting point is

https://cknotes.com/office365-modern-authentication-for-imap-pop3-and-smtp/

It has links to other posts and examples for more detailed information. Please have a look to see if it helps.

*** Also, in the Azure AD console where you create your App, create a "web app" -- even though technically it's not a web app, your application is acting as a temporary web server when Chilkat (in a background thread) receives the redirect..

*** Also, make sure to understand the Microsoft account types w.r.t. your registered App: https://learn.microsoft.com/en-us/security/zero-trust/develop/identity-supported-account-types You'll want to choose the appropriate account type for your App defined in Azure based on your needs.

Chilkat Software
  • 1,405
  • 1
  • 9
  • 8
  • I apparently didn't get that memo! Looking over your references it looks like this will be fun! Not. But it sounds like you have been having "fun" figuring this out as well. – Brad Mathews Mar 24 '23 at 00:41