Wrong encoded characters into Attachment Name

Hi. Same issue as here. Everytime we retrieve the value of the “Name” property of Attachment class, even if the original name is correct with an accented letter (if you open the eml file with a text editor you can easily check it), the value returned from the property is wronged encoded with the symbol “�”. Please could you fix this bug? If not, could you add another property with the raw value of file name? We have serious problems with our customers to retain original filenames. We just renewed the license but if a solution is not found we will be forced to give up the library.

@biagio_carratu_dedagroup_it,

Please refer to following elaboration in the thread.

We have shared the explanation as it is not related to Aspose.Email.

We don’t convert the string. We simply retrieve the mail list from a mail server with the ImapClient. After that we process one MailMessage object at a time and then we only access the property “Name” of Attachment object without encoding.
This is the original raw content extracted from an email:

IHRpcG9SaWZlcmltZW50bz0iTUlNRSI+CiAgICAgIDxUaXRvbG9Eb2N1bWVudG8+Vk9aWkEgVklO
Q0VOWk8gUEVSIFBBUlRJTklDTyBVUkdFTlRF2TwvVGl0b2xvRG9jdW1lbnRvPgogICAgPC9Eb2N1
bWVudG8+CiAgPC9EZXNjcml6aW9uZT4KPC9TZWduYXR1cmE+Cg==
------=_Part_11198_1292473254.1582543607349
Content-Type: application/octet-stream; 
	name="This_is_a_bùg.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; 
	filename="This_is_a_bùg.pdf"

JVBERi0xLjQKJeLjz9MNCjQgMCBvYmoKPDwKL0NvbnRlbnRzIDUgMCBSCi9NZWRpYUJveCBbIDAg

and when we retrieve the value from the Name property of the Attachment class we get the wrong character into the string:
“This_is_a_b�g.pdf”.

@biagio_carratu_dedagroup_it,

I have observed the issue shared by you. I request you to please share the source MSG file with attachment having issue in getting name along with used sample code. We will investigate that further on our end to help you out.

Hi, this is the eml file. The target attachment name contains the ‘ù’ character.
637.eml.zip (73.6 KB)

the original code is the sequence of ImapClient using:

  • call the ListMessagge method,
  • iterate over the MailMessageInfo
  • call FetchMessage method
  • process MailMessage
  • access Attachment list
  • for each attachment access Name Property

the behaviour is reproducible also with direct file loading into MailMessage using Load static method
Here the sample code

[TestMethod]
public void AttachmentNameTest()
		{
			Aspose.Email.License license = new Aspose.Email.License();
			license.SetLicense("../../Aspose.Email.lic");
			string basePath = "../../Data/ProveMail/Encoding";
			string fileName = "637.eml";
			string fullPath = basePath + "/" + fileName;
			var message = MailMessage.Load(fullPath);
			var internalMessageAttachment = message.Attachments.FirstOrDefault(x => x.Name == "postacert.eml");
			var internalMessage = MailMessage.Load(internalMessageAttachment.ContentStream);
			var attachments = internalMessage.Attachments;
			var name = string.Empty;
			foreach (var a in attachments)
			{ 
				name = a.Name;
				Console.WriteLine(name);
			}
		}

We’re using .Net Framework 4.6.1

@biagio_carratu_dedagroup_it,

I have worked with the sample file shared by you and have created an issue with ID EMAILNET-39753 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

The issues you have found earlier (filed as EMAILNET-39753) have been fixed in this update.