Aspose Email Attachment's Issue - Getting different attachment's name for same file

Aspose Email attachment’s name issue for same .eml file & .msg file

We have below two scenarios for processing file with Aspose.Email.

Scenario – 1 , In this scenario we are processing .eml file with Aspose.Email and getting list of attachments.

Scenario-2 , In this scenario we are exporting same .eml file in .PST , after exporting .PST we are extracting .msg file from .PST and we are processing same .msg with Aspose.Email.

In these two scenarios we are getting different attachment’s name.

We are getting below difference in attachment’s name

  1. Extension
    a. In case of .eml file it does not give any .extension for attachment’s name
    b. While in case of .msg file it gives attachment’s name with extension (.msg)

  2. Colon
    a. In .eml file we are getting Colon (:slight_smile: in attachment’s name
    b. While in .msg file we are not getting Colon (:slight_smile: in attachment’s name

  3. Slash
    a. In .eml file we are getting forward Slash (/) in attachment’s name
    b. While in case of .msg file we are not getting any Slash(/) attachment’s name

We are using Aspose.Email version is 24.9.0

We have attached differential screenshots.
PFA.

Let us know if any query or concern from your side.

Attachment_Extension.png (100.0 KB)

Attachment_Slash.png (112.9 KB)

Difference_AttachmentName_Colon.png (103.2 KB)
Attachment_Extension.png (100 KB)
Attachment_Slash.png (113 KB)
Difference_AttachmentName_Colon.png (103 KB)

@Sangram_Sinh,

Thank you for sharing the details and screenshots regarding your issue.

I will transfer your thread to the appropriate forum/category so that one of our colleagues from the Aspose.Email team can review your problem and provide assistance soon.

@amjad.sahi
Thank you for your quick response.
I will wait for your response regarding this issue.

Hello @Sangram_Sinh,

Thank you for sharing the details.
To further investigate this issue, we’ll need the following:

  • Sample code, that you are using in both scenarios (processing .eml directly and processing .msg extracted from .pst).
  • Sample input files (.eml, the corresponding .pst and extracted .msg) where you are observing the difference in attachment names.

This will help us reproduce the problem on our side and provide you with a proper analysis.

Hi @margarita.samodurova ,
Thank you for your response .

We are attaching here all required files so it will help you for troubleshoot in details.

Aspose Email Attachment’s Issue.zip (31.0 KB)

public EmailNote(MapiMessage mapiMessage, Stream stream) : base(stream)
{
    _msg = mapiMessage;
    AttachIndex = new List<int>();
    _emailAttachments = new Lazy<List<EmailAttachment>>(() =>
    {

        var cList = new List<EmailAttachment>();
        int index = 0;

        for (var i = 0; i < _msg.Attachments.Count; i++)
        {
            var a = _msg.Attachments[i];

            if (!a.IsLinked() && !a.IsHidden(_msg) && (a.ObjectData != null || a.BinaryData != null))
            {
                cList.Add(new EmailAttachment(index.ToString(), a.LongFileName ?? a.FileName));
                index++;
                AttachIndex.Add(i);
            }
        }
        return cList;
    });
}

Let me know if any concern from your side

Hello @Sangram_Sinh,

Thank you for providing the details. Our team will analyze them and follow up with you soon.

Hello @Sangram_Sinh,

We tried to reproduce the issue on our side using version 24.9.0, but the attachment names are retrieved correctly in both scenarios. Please see the sample code below that follows the steps you described:

string fileName = "EML_Attachment_Colon_28.eml";
string fileName2 = "EML_Attachment_Extension_1277.eml";
string pstfileName = "test.pst";
File.Delete(pstfileName);

var mailMessage = MailMessage.Load(fileName);
var mailMessage2 = MailMessage.Load(fileName2);

using (PersonalStorage pst = PersonalStorage.Create(pstfileName, FileFormatVersion.Unicode))
{
    FolderInfo folder = pst.RootFolder.AddSubFolder("Inbox");

    string entryId = folder.AddMessage(MapiMessage.FromMailMessage(mailMessage));
    string entryId2 = folder.AddMessage(MapiMessage.FromMailMessage(mailMessage2));

    MapiMessage mapiMessage = pst.ExtractMessage(entryId);
    MapiMessage mapiMessage2 = pst.ExtractMessage(entryId2);

    Console.WriteLine("eml name: " + mailMessage.Attachments[0].Name);
    Console.WriteLine("eml name2: " + mailMessage2.Attachments[0].Name);
    Console.WriteLine("msg name: " + mapiMessage.Attachments[0].FileName);
    Console.WriteLine("msg name2: " + mapiMessage2.Attachments[0].FileName);
}

With this code, attachment names are consistent and we don’t observe the differences you mentioned.

Could you please share your exact processing code where you read the attachment names?

Once we have your actual code for extracting the names, we’ll be able to check further.