We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

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.


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:

Content-Type: application/octet-stream; 
Content-Transfer-Encoding: base64
Content-Disposition: attachment; 


and when we retrieve the value from the Name property of the Attachment class we get the wrong character into the string:


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

public void AttachmentNameTest()
			Aspose.Email.License license = new Aspose.Email.License();
			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;

We’re using .Net Framework 4.6.1


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.