Receiving EMails is possible using the pop3 adapter of Microsoft Biztalk Server 2006. But if you want to save multiple attachments with their original filename, you have to do a little detour with an orchestration.
Following process steps have to be defined:
- Create a new Biztalk Project with help of Visual Studio – Insert an new blank orchestration
- Definition of a unidirectional receive port with communication direction “I always receive messages on this port” and port binding “Define later”
- Definition of a unidirectional send port with communication direction “I always send messages on this port” and port binding “Define later”
- Definition of process and the variable nCount of type Int32 (Init value 1)
- Compile and provide the orchestration
- Create a receive port type POP3 with help of Biztalk Management Tool – Port Configuration with the credentials of you POP3 servers. Important is to set the option “MIME Decoding” to true
- Create a send port of type file (e.g.) with help of Biztalk Management Tool – Port Configuration. It is important using makro %SourceFileName%
- Activating ports, bind the ports to the orchestration
- Starting the orchestration
Process step GetCount determine the amount of included attachments and save it to the variable nCount
//Set the input message to a var of XLang Message type oXMessage = In; // Get count nCount = oXMessage.Count;
Process step MessageAssignment is called in a loop and transfers one attachment after the other to the send port. The original filename is transfered by MIME.FileName to the File.ReceivedFileName property of the send port, so that with help of the macro %SourceFileName% the original filename can be reused.
//Get the n'th part and set to a new message Out = oXMessage[n]; Out(FILE.ReceivedFileName) = Out(MIME.FileName); // Add to count n = n + 1
Download of the Orchestration