Debatching excel sheet attachments using POP3 adapter

Hi,

I have tried implementing link : BizTalk Server: How to Extract Email Attachments By Pipeline

for debatching the excel files as an attachment through POP3 adapter. It works fine for the text files but I receive an corrupted file while testing for excel files. It says "excel cannot open file.xlsx because the file format or file extension is not valid. Verify that the file has not been corrupted and the file extension matches the format of the file".

Please suggest.

Thanks in advance.

Ranjana

September 3rd, 2015 6:54am

Hi Ranjana,

I Agree there is a bug in that code, have fixed that now with the below code.

Please replace the below lines code with this.

string attachmentContent = Encoding.Default.GetString(ms.ToArray());

MemoryStream attachmentStream = new System.IO.MemoryStream(System.Text.Encoding.Default.GetBytes(attachmentContent));

Have tested the 3 scenarios.

- Text file

- XML file

- Excel File

Let us know if you face any issue again.

Thanks, SMSVikasK

Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 11:15am

Hi Ranjana,

I suggest you to look the comments shared by "Maurice CGP Peters" to handle multiple attachments for file names.

for (int j = 0; j < inmsg.Context.CountProperties; j++)
{
string currentName;
string currentNamespace;
object obj = inmsg.Context.ReadAt(j, out currentName, out currentNamespace);
outMsg.Context.Write(currentName, currentNamespace, obj);
if (inmsg.Context.IsPromoted(currentName, currentNamespace))
{
   outMsg.Context.Promote(currentName, currentNamespace, obj);
}
}

Thanks, SMSVikasK

September 3rd, 2015 11:24am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics