BizTalk Server - POP3 Adapter - Basic Authentication Depreciation Workaround Solution

Workaround for Microsoft BizTalk Server POP3 Adapter – Basic Authentication Depreciation

This document is about Basic Authentication used in Microsoft BizTalk Server POP3 adapter.

There would be scenario where you would have used the Microsoft BizTalk Server POP3 adapter at the receive location to connect Outlook and read the emails with or without attachments. This adapter uses common form of authentication known as Basic Authentication using username and password to connect to Outlook.

Recently, Microsoft have announced that they will depreciate the basic Authentication in Exchange online. Details of which can be viewed in the link mentioned below.

Basic Authentication Deprecation in Exchange Online – September 2022 Update - Microsoft Community Hub

This announcement was done nearly three years ago.

Starting October 1st, they will disable the access for protocol in scope which are mentioned as below. List consists of POP3 as well. Thus, your solution of using POP3 adapter to connect to outlook will not work in older versions of BizTalk Servers which uses basic authentication. It will work in latest versions of BizTalk as they use the modern Authentication like OAuth and others.

List of Protocols: -

MAPI
RPC
Offline Address (OAB)
Exchange Web Services (EWS)
POP
IMAP
Exchange ActiveSync (EAS)
Remote PowerShell


From Microsoft’s end, there is no alternative solution, other than forcing us to migrate from BizTalk server 2010 or 2013 to 2016 or latest 2020. But if you are not in the position to migrate, and if you have only limited Azure Cloud exposure then below solution will work for you. But if you are yet not there in cloud then this might not help but will give you some idea on how to move on from POP3 adapter.

 

For many of us, it would be not possible to migrate the apps that quickly in newer version of BizTalk or to Azure cloud.

Thus, as a workaround I have come up with hybrid solution to use Azure Logic app, to read the emails and export the emails files to BizTalk server's Folder location, instead of using the POP3 Adapter.

BizTalk File Receive location would then read the exported email files with the help of custom pipeline which I created to convert the email file to desired message and promote the POP3 Properties.

This solution works seamlessly, as message created will be same as message created by pop3 adapter, thus there no further changes is required in any other artifacts like orchestration and send ports.

So, for the BizTalk to read the emails from Folder location, you will have to export the emails that you receive in your mailbox through the Azure Logic App. In Azure Logic App, use the Azure Outlook connector to connect to Outlook account with the help of trigger When new mail arrives(V3) and read the email, and next in the action use the Export email option of the Outlook connector to export the email file. Email will be exported with extension .EML


Below is the step for creating Azure Logic Apps.

1.    Sign in to the Azure portal with your Azure account.

2.    In the Azure search box, enter logic apps, and select Logic apps.



3.    On the Logic apps page, select Add.




  1. On the Create Logic App pane, on the Basics tab, create subscription or select the existing one. Give appropriate name, Select Region you wish to deploy your logic app and select the plan Type Standard or Consumption. When you're done, your settings look similar to this version:



5.    When you're ready, select Review + Create.

6.    On the validation page that appears, confirm all the information that you provided, and select Create.

7.    After Azure successfully deploys your app, select Go to resource.

8.    Under Templates, select Blank Logic App.



        9.    Under the designer search box, select AllIn the designer search box,                 enter Outlook. From the Triggers list, select the Office 365 Outlook trigger, When a             new email arrives (v3).


11. Email service prompts you to sign in and authenticate your identity, complete that step now. Authenticate your identity before you can continue. This is using the modern authentication to connect to outlook. This helps in solving the issue of pop3 adapter basic authentication issue.



12. Make sure you select Include Attachment to Yes to read the attachments as well 



13. Next, to export the email, in the action bar again search for outlook and From the Action list, select the Office 365 Outlook, Export email (V2) 



14. This will convert the email arrived to the .EML file and by using the file create file action you can save the file to desired location like shared server or the BizTalk Server folder.( note - to connect to the Server for writing the files, you would require the OnPremData Gateway installed on the server and configured at the portal as well). you can give guid or and any unique name to the file.

          Once the LogicApp is created to read and Export email, it will export the email files to the folder mentioned with ".EML" extension. 

            Now in BizTalk to read the .EML files which are nothing, but MIME encoded email Files, we have to create the BizTalk Receive Pipeline.

Steps for creating the Pipeline are below. 

I will not mention all the detailed steps for creating the pipeline but will mention only the key steps are mentioned below. 

1.    Create a receive pipeline and add the standard MIME/SMIME decoder pipeline to the decode stage of the pipeline.


2.    Now, since we are not using the POP3 adapter, we will have to promote few properties by using the custom pipeline component which we will have to create and drag it to the decode stage before the MIME/SMIME. 

    3.    The custom pipeline component writes (not promotes) an undocumented context property called CopyMailHeadersToContext to the message context before passing it to the MIME/SMIME pipeline component – this tells the component to add some POP3 properties to the message context as well. So if you have MIME encoded emails being forwarded to BizTalk via file, FTP or otherwise (usually files with a .eml extension), you can reproduce the adapter’s behaviour by creating a very simple pipeline component to write the CopyMailHeadersToContext property with the POP3 adapter namespace and a value of 3 (don’t ask me why 3, still not sure about this value), then place it just before the MIME/SMIME pipeline component in the decode stage of a receive pipeline:

    



            4. This is the execute method of the pipeline component, almost as simple as it gets:
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
{
   //By writing this to the context we tell the MIME/SMIME decoder to
   //populate the POP3 context properties while going through the email message
   pInMsg.Context.Write("CopyMailHeadersToContext", 
   "http://schemas.microsoft.com/BizTalk/2003/pop3-properties", 3);
   return pInMsg;
} 

5.  Compile and deploy the pipeline
6.  Create a receive port and receive location that picks up *.eml 
     from the location where Azure Logic App writes the file
7.  Use the receive pipeline that you created in point 5
8.  Bind the receive port to a pass through send port.
9.  Start the ports and the hosts.


Reference for the custom pipeline - 
Receiving MIME encoded email files and a hidden POP3 context property - Connected Thoughts (connected-thoughts.com)

 

Hope this workaround solution is useful to you, if you have access to Azure as well as if you are not yet ready to move from older BizTalk version to the latest ones, and you want to overcome the POP3 adapter Basic Authentication depreciation issue.

 

Let me know in the comments if you have any doubts.




Comments