Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7768591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:57:09+00:00 2026-06-01T15:57:09+00:00

Can anyone recreate this issue? It seems to me like a quite serious bug

  • 0

Can anyone recreate this issue? It seems to me like a quite serious bug in SmtpClient (.NET 4.0) but I can’t believe no one has seen this before and Google doesn’t seem to show anyone seeing a similar issue.

When sending an email with more than 1 attachment and the ‘Attachment.Name’ property is used, the attachments will have the incorrect names (e.g. 2 attachments will have their names swapped). The work around (and actually probably the correct property to set) is to use ContentDisposition.FileName. But I would be very interested if this happens for everyone. Can anyone recreate this issue? It seems to me like a quite serious bug in SmtpClient (.NET 4.0) but I can’t believe no one has seen this before and Google doesn’t seem to show anyone seeing a similar issue. You’ll need to create a couple of zip files in c:\tmp\emailin\

var zipCt = new ContentType { MediaType = MediaTypeNames.Application.Zip };

var attachmentA = new Attachment(@"c:\tmp\emailin\a.zip", zipCt);
attachmentA.ContentDisposition.FileName = "a.zip";
attachmentA.Name = "a.zip";

var attachmentB = new Attachment(@"c:\tmp\emailin\b.zip", zipCt);
attachmentB.ContentDisposition.FileName = "b.zip";
attachmentB.Name = "b.zip";

var msg = new MailMessage("testfrom@example.com", "testto@example.com")
{
       Body = "body",
       Subject = "subject"
};
msg.Attachments.Add(attachmentA);
msg.Attachments.Add(attachmentB);

using (var smtp = new SmtpClient())
{
     smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
     smtp.PickupDirectoryLocation = @"c:\tmp\emailout\";
     smtp.Send(msg);
}

If you now look at the eml file in c:\tmp\emailout\ you will see something like

X-Sender: testfrom@example.com
X-Receiver: testto@example.com
MIME-Version: 1.0
From: testfrom@example.com
To: testto@example.com
Date: 11 Apr 2012 12:36:48 +0100
Subject: subject
Content-Type: multipart/mixed; boundary=--boundary_0_1b7bb1ee-ba28-4258-b662-554adb7ff81a


----boundary_0_1b7bb1ee-ba28-4258-b662-554adb7ff81a
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable

body
----boundary_0_1b7bb1ee-ba28-4258-b662-554adb7ff81a
Content-Type: application/zip; name=b.zip
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=a.zip

UEsDBAoAAAAAAG5ki0AAAAAAAAAAAAAAAAAFAAAAYS50eHRQSwECPwAKAAAAAABu
ZItAAAAAAAAAAAAAAAAABQAkAAAAAAAAACAAAAAAAAAAYS50eHQKACAAAAAAAAEA
GADa2JQw1xfNAdrYlDDXF80B2tiUMNcXzQFQSwUGAAAAAAEAAQBXAAAAIwAAAAAA
----boundary_0_1b7bb1ee-ba28-4258-b662-554adb7ff81a
Content-Type: application/zip; name=a.zip
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=b.zip

UEsDBAoAAAAAAHZki0AAAAAAAAAAAAAAAAAFAAAAYi50eHRQSwECPwAKAAAAAAB2
ZItAAAAAAAAAAAAAAAAABQAkAAAAAAAAACAAAAAAAAAAYi50eHQKACAAAAAAAAEA
GAD67/k51xfNAfrv+TnXF80B2tiUMNcXzQFQSwUGAAAAAAEAAQBXAAAAIwAAAAAA
----boundary_0_1b7bb1ee-ba28-4258-b662-554adb7ff81a--

Note how the Content-Type: and Content-Disposition: file names do not match for each attachment.

Am I doing something wrong? Is this a bug that I should log with MS?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:57:10+00:00Added an answer on June 1, 2026 at 3:57 pm

    This is because you require a new instance of ContentType for each attachment.

    var zipCt = new ContentType { MediaType = MediaTypeNames.Application.Zip };
    var zipCt2 = new ContentType { MediaType = MediaTypeNames.Application.Zip };
    
    var attachmentA = new Attachment(@"c:\tmp\emailin\a.zip", zipCt);
    attachmentA.ContentDisposition.FileName = "a.zip";
    attachmentA.Name = "a.zip";
    
    var attachmentB = new Attachment(@"c:\tmp\emailin\b.zip", zipCt2);
    attachmentB.ContentDisposition.FileName = "b.zip";
    attachmentB.Name = "b.zip";
    

    Should fix your issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone explain to me why this program: for(float i = -1; i <
Can anyone help - this is driving me mad. I am calling a mysql
Can anyone tell me why this code would not be working? $('body').on('test', function() {
I'm trying to recreate a modernized version of this tutorial here - but I'm
can i destroy base class and recreate it in derived with this trick? class
Can anyone tell me what exactly does this Java code do? SecureRandom random =
In this small, but full example, I am trying to recreate a dual list
I'd like to recreate a view that you can zoom like the iPhone/iPad Mail
Can anyone let me know how can we change the value of kendo combobox
Can anyone enlighten me to a way I can Highlight the content of an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.