Quantcast
Channel: BizTalk Server Adapters and Adapter Pack Forum
Viewing all articles
Browse latest Browse all 197

POP3 Adapter Attachment Name

$
0
0

When sending an e-mail with attachments directly from Outlook 2010 to contactcentre@mycompany.com, a BizTalk Server 2010 application has a receive location using the POP3 adapter to process this e-mail and each attachment message part contains the correct name of the attachment, e.g. myfile.pdf.

However, when I create an e-mail with attachments programmatically in C# using System.Net.Mail.SmtpClient, the POP3 Adapter does not seem to recognise the attachment names and the name of the attachment message part instead becomes a GUID. I suspect that this has something to do with encoding. What am I doing wrong in the code?

Here is the code:

SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["SmtpServer"]);
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage mailMessage = new MailMessage(ConfigurationManager.AppSettings["From"], ConfigurationManager.AppSettings["To"], ConfigurationManager.AppSettings["Subject"], ConfigurationManager.AppSettings["Body"]);
string[] files = ConfigurationManager.AppSettings["Attachments"].Split(',');
foreach (string file in files)
{
    FileInfo fileInfo = new FileInfo(file);
    ContentType contentType = new ContentType();
    contentType.MediaType = GetMimeType(file);
    contentType.Name = fileInfo.Name;
    Attachment attachment = new Attachment(file, contentType);
    attachment.ContentDisposition.FileName = fileInfo.Name;
    attachment.Name = fileInfo.Name;
    mailMessage.Attachments.Add(attachment);
}
smtpClient.Send(mailMessage);

The strange thing is that when I view the message in Outlook 2010, the attachment name appears correct.

I need the POP3 Adapter to interpret the attachment name correctly instead of setting it to a GUID.

Any ideas?


Viewing all articles
Browse latest Browse all 197

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>