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

Free Support Forum - aspose.com

Identifying Bounce emails

Hi

I am using Aspose.Email.Imap.ImapClient Fetchmessage to fetch emails from a mailbox.I need to identify undeliverable messages from the mailbox.How can i achieve that? I tested Aspose.Email.Mail.Message checkbounced().isbounced , but it is always returning false.

Thanks

Hi Veena,


Thank you for writing to Aspose Support team.

We have tested this issue with the latest version of Aspose.Email for Java 17.2.0 and were not able to reproduce it at our end. The bounced message is identified correctly by the API. Please download the sample message that fails this test and share with us. We’ll load it in MailMessage to reproduce the issue at our end and assist you further.

Hi Kashif,


Attached the eml that failed to identify as bounced email.I used Aspose.Email 17.2 .net.
Thanks,

Hi Veena,


Thank you for sharing the sample MSG file.

We have tested it at our end with the latest version of Aspose.Email for .NET 17.2.0 and the message is correctly identified as bounced. Could you please run the code at your end and share output image with us?

Sample Code

Aspose.Email.FileFormatInfo fileInfo = Aspose.Email.FileFormatUtil.DetectFileFormat(“832080\Undeliverable_ TestFailure.eml.msg”);

Console.WriteLine(fileInfo.FileFormatType);

MailMessage mail = MailMessage.Load(“832080\Undeliverable_ TestFailure.eml.msg”, new MsgLoadOptions());

BounceResult result = mail.CheckBounced();

Console.WriteLine(result.IsBounced ? “It is bounced message.” : “It is normal message”);

Thanks Kashif,


As i said initially i used Fetchmessage to initiate a Mailmessage, and it was returning false always.Snippet below.

//Note: imap is ImapClient object
MailMessage msg = imap.FetchMessage(message.UniqueId);
BounceResult result = msg.CheckBounced();
LogProvider.Log(GetType()).Info(result.IsBounced ? “bounced message.” : “valid message”);

I tried to save the message as eml and tried to check the bounced status, which also returned false for all messages.Code below
//Note: imap is ImapClient object
MailMessage msg = imap.FetchMessage(message.UniqueId);
msg.Save(“C:\temp\Undeliverable_ TestFailure.eml”, new EmlSaveOptions(MailMessageSaveType.EmlFormat));
MailMessage m = MailMessage.Load(“C:\temp\Undeliverable_ TestFailure.eml”, new EmlLoadOptions());
BounceResult result = m.CheckBounced();
LogProvider.Log(GetType()).Info(result.IsBounced ? “bounced message.” : “valid message”);

Also tried to save as Outlookmessage instead of eml but it is giving the same result.

I saved the message directly from outlook to disk and that was able to identify bounced messages.

Thanks,




Hi,


We are not sure if it is related to some server side behavior, but we were not able to reproduce the issue at our end by appending your sample MSG file to our test account. The message, when fetched from the test account, was identified correctly as bounced message. You can also try it with the following code sample that contains the credentials for the Exchange account on Office365. If possible, please create a test account on your server, put the bounced message in it and share its credentials with us so that we can reproduce the same issue at our end for assisting you further.

Sample Code

ImapClient client = new ImapClient(“outlook.office365.com”, 993, "UserOne@AsposeMar2017.onmicrosoft.com", “Aspose1234”);

client.SelectFolder(ImapFolderInfo.InBox);

ImapMessageInfoCollection msgsColl = client.ListMessages();

MailMessage eml = client.FetchMessage(msgsColl[0].UniqueId);

Console.WriteLine("Fetched Message: " + eml.Subject);

BounceResult result = eml.CheckBounced();

Console.WriteLine(result.IsBounced ? “It is bounced message.” : “It is normal message”);

Thanks Kashif,


It looks like only an issue with our mailserver.I did a test against another mailserver which was able to identify bounced messages with same code.

We can close this now
Veena

Hi Veena,


You are welcome and please feel free to write to us if you have any further query related tot the API.