Not detecting Attachments

Hi Support,

The attached ZIP file contains a email and it contains attachment.

I am using "Aspose.Email.Mail.MailMessage" to read the email. When i check it says no attachments are available. Where as there is a attachment in the email.

Please Help,

Cheers,

ValuePRO

Hi Piers,


I was able to observe the issue using the latest version of Aspose.Email for .NET 2.7.0 and have logged it in our issue tracking system under issue id: NETWORKNET-33691. I’ll write back here once there is any information available and appreciate your patience in this regard.

Hi Support,

Is there any update on this issue.

Cheers,

ValuePRO

Hi Piers,


I have checked the status of this issue from our issue tracking system and have found that it has been scheduled to be fixed as part of the upcoming product release Aspose.Email for .NET 2.8.0. As this thread has already been associated with the logged ticket, you’ll be notified automatically once the fix version is available.

Hi,


I don’t know if it’s the same problem but when I have more than one attahement, I cannot retreive the first one. I tested with two attachement and only the 2nd one is available. The first one crash with this error: cf attachement

Here is my source:

//Call EML Object
Stream stream = new MemoryStream((byte[])command.ExecuteScalar());
mymail.Import(stream);

CountAtt.Text = mymail.Attachments.Count().ToString(); //Count the number of attachement
int i = 0; // int to count index

foreach (Aspose.Email.Mail.Attachment Att in mymail.Attachments)
{
ListAtt.Text = ListAtt.Text + "; " + Att.Name; // Create the Attachement list
if (Att.Name == Attachment) // Attachement is a parameter to retreive file based on the name
{
SelectedAtt.Text = Att.Name; //Save the Selected Attachement Name.
SelectedAttIndex.Text = i.ToString(); //Save the Attachement Index
sAtt = Att.ContentStream; //Save the Selected Attachement in a Stream
}
i++;
}

Regards
Guillaume

Hi Piers,


Could you please provide us with such a sample file, possessing such issue with multiple attachments, for our investigation? We’ll look into it and share our findings here as well. If this would be an issue at Aspose.Email end, we’ll log it into our issue tracking system for consideration by our development team.

Looking forward to assist you further.

Hi Kashif,

I don't have any example with multiple attachments. The one originally attached was havinf only one attachment with file extension .axz.

Cheers,

ValuePRO

Hi Piers,

DL-SGA-A78Admins:
Hi,
I don't know if it's the same problem but when I have more than one attachment, I cannot retrieve the first one. I tested with two attachment and only the 2nd one is available. The first one crash with this error: cf attachement.

I assumed that you have tested it with some sample file that we can use to reproduce this issue at our end.

I have tested this and all attachments, in a test email message at my end, are extracted properly at my end using the latest version of Aspose.Email for .NET 2.7.0. The issue may be specific to your sample data file, which if provided to us, we can look into it and assist you further.

Hi,

You right, In copy, you will find the eml example that I used to make my test. I tested it also with the last version of the DLL but I have the same error.

Regards

Guillaume

Hi Piers,


Thank you for providing the eml file.

After analyzing the eml file, I can see that there are some garbage characters at the beginning of this email, as you can see in the attached screenshot (taken by opening the eml file in notepad). If these are removed, the eml is loaded fine using Aspose.Email and attachments are saved properly.

It seems that the message extracting process at your end is attaching some extra bytes at the beginning of the eml file. Please give it a try at your end by removing the initial garbage characters and let us know your feedback.

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi,


Sorry but I have still the same problem. The error is not special charatar which are before Return-Path. Here I have two eml. For one it’s working, I can display the attachement for the 2nd one, it’s not working.

I update the dll with the last version 2.8 but I have still the same problem.

If you want, I am ready to make a webex session or something like that to show you.

Regards
Guillaume

Hi Guillaume,

Could you please confirm to us if you have properly referenced Aspose.Email for .NET 2.8.0 DLL in your code? I have tried to reproduce your mentioned issue with this latest version, but I am afraid to share that I couldn’t observe this issue and both emails are not only detected using Aspose.Email but are also properly extracted from both the EML files. I have used the following code and attached the extracted PDF files here for your reference as well.

If the issue still persists at your end, please provide us a running sample application to reproduce this issue at our end. We’ll look into for assisting you further.

Sample Code:

string dir = "EMAIL_460558//";
MailMessage eml = MailMessage.Load(dir + "CanOpenAtt.eml", MessageFormat.Eml);
Console.WriteLine("Total Number of Attachments in CanOpenAtt.eml: " + eml.Attachments.Count);
foreach (Attachment att in eml.Attachments)
    att.Save(dir + att.Name);
eml = MailMessage.Load(dir + "CannotOpenAtt.eml", MessageFormat.Eml);
Console.WriteLine("Total Number of Attachments in CannotOpenAtt.eml: " + eml.Attachments.Count);
foreach (Attachment att in eml.Attachments)
    att.Save(dir + att.Name);

Hi,


Thank you for your quick reply. I retreive the EML file from SQL Binary field and I load it into a stream like that:

To make a debug, Change little bit my code to update labels:

Stream stream = new MemoryStream((byte[])command.ExecuteScalar());
mymail.Import(stream);
//On récupére le fichier attaché
Stream sAtt = null;
CountAtt.Text = mymail.Attachments.Count().ToString(); //Count the number of attachement
int i = 0;
foreach (Aspose.Email.Mail.Attachment Att in mymail.Attachments)
{
ListAtt.Text = ListAtt.Text + "; " + Att.Name; // Create the Attachement list
if (Att.Name == Attachment)
{
SelectedAtt.Text = Att.Name; //Save the Selected Attachement.
SelectedAttIndex.Text = i.ToString();
sAtt = Att.ContentStream;

}
i++;
}

and here is the result:

When it’s not working, I do not see the SelectedAtt and SelectedAttIndex

AVM-FAXBIS-1_1URioV-0002KD-20-357084.eml
CountAtt:
1
ListAtt: ;
M&C_PURCHASE_ORDER.PDF

SelectedAtt:
SelectedAttIndex:

When it’s working I can see it:

AVM-FAXBIS-2_1USRAg-0000TF-2g-349187.eml
CountAtt:
1
ListAtt: ;
SALPurchaseOrderP11581.pdf

SelectedAtt: SALPurchaseOrderP11581.pdf
SelectedAttIndex:
0

Regards
Guillaume

Hi Guillaume,

I was still unable to observe this issue at my end. Please have a look at the following code sample for your reference that not only displays the attachment counts and names, but also saves these to disc properly. I have also attached a test project here for your reference. Please let us know your feedback.

Code Sample:

byte[] btArray = File.ReadAllBytes("CanOpenAtt.eml");
MemoryStream ms = new MemoryStream(btArray);
ms.Position = 0;
MailMessage eml = MailMessage.Load(ms);
Console.WriteLine("Total Number of Attachments in CanOpenAtt.eml: " + eml.Attachments.Count);
foreach (Attachment att in eml.Attachments)
{
    Console.WriteLine("Saving Attachment: " + att.Name);
    att.Save(att.Name);
}
btArray = File.ReadAllBytes("CannotOpenAtt.eml");
MemoryStream ms2 = new MemoryStream(btArray);
ms2.Position = 0;
eml = MailMessage.Load(ms2);
Console.WriteLine("Total Number of Attachments in CannotOpenAtt.eml: " + eml.Attachments.Count);
foreach (Attachment att in eml.Attachments)
{
    Console.WriteLine("Saving Attachment: " + att.Name);
    att.Save(att.Name);
}

Hi,


You right, Your solution is working perfectly. I also tested to connect to SQL server database and it’s working too. Now could you please tell me how I can retreive an attachment based on the name or based on the index or based on the contentID to avoid a foreach loop?

Finally my problem seems to be at this level when I want to select a specific attachement.

Regards
Guillaume

Hi Guillaume,


Thank you for the feedback.

I investigated to find any such method for getting attachments directly, but I don’t think so there is any such method available and the attachments have to be accessed one by one in a foreach loop unless you want to access these by specific index. If I find something similar, I’ll share with you here.

Hi,


Thank you for your great support. I found a way to open attachement based on the Index. So first, I have a web page which list all attachment with index and by clicking on a link, it open a segond page to open the attachment based on his index. So that’s perfect.

Again, Thank you very much for your patience and your help. The small project that you did, help me to identify my problem.

Regards
Guillaume

Hi Guillaume,


Thank you for the feedback.

It’s good to know that the sample project solved your problem. Please let us know if you need any further assistance related to Aspose.Email. I’ll be glad to help you further.