POP3 Adapter Attachment Name RRS feed

  • Question

  • When sending an e-mail with attachments directly from Outlook 2010 to, 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;

    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?

    Friday, January 4, 2013 4:50 PM