FormatException: The specified string is not in the form required for an e-mail address on creating MailAddress

Hi,
Exception when I’m trying to create MailAddress with address of format :
/O=EXCHANGE HOSTING/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=JKUTSTORY_CSAI

MailAddress tmp = new MailAddress("/O=EXCHANGE HOSTING/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=JKUTSTORY_CSAI");

But actually this is something that should be accepted , as this is arrived from the Office 365 Exchange. I think this was fixed in the past (few years ago) and now we see it again.
Please advise.
Thanks

@slavago,

I have observed the issue shared by you and request you to please first try using latest Aspose.Email for Java 19.9 on your end. In case the issue still persist then please share the working sample code along with test account details reproducing the issue on your end so that we may proceed further with investigation on our end.

Did you read my message?
This line is the working sample with all needed information to reproduce the problem :

MailAddress tmp = new MailAddress("/O=EXCHANGE HOSTING/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=JKUTSTORY_CSAI");

So, please run it on your end.
Thanks

@slavago,

I have tested the sample code line for adding MailAddress shared by you. The exception that is thrown is wrong email format exception. Are you sure if you are adding email w.r.t correct email format in constructor argument.

Yes, this is correct email address returned by Exchange, office 365 (corporate). And this was working in the past, few years ago, if I remember correctly, you guys fixed same issue. But , anyway this ia valid responded email from Exchange.
Please fix this as it broken or provide any other way set email address within corporate Exchange.
Thanks

@slavago,

Thank you for your feedback. An issue with ID EMAILJAVA-34601 has been added in our issue tracking system to investigate the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Thanks, I appreciate that

@slavago,

Your are very welcome.

I am experiencing the same problem (with .NET version). Office 365 sometimes generates MSG with non-standard email address, which causes:

new Aspose.Email.MailAddress(String address, String displayName)

to throw “The specified string is not in the form required for an e-mail address” exception. I think Aspose is attempting to validate the provided address according to ‘standard’ email address rules. But Office 365 seems to use its own non-standard sometimes.

I think best & simple solution would be option to disable email address validation in Aspose.Email.MailAddress class, if user does not need/want it.

Thanks

@ast3,

Can you please share source file along with sample project to reproduce issue so that we may help you out.

Hi Adnan,

The problem is that Office 365 sometimes generate MSGs that have non-standard email addresses, which causes instantiation of new Aspose.Email.MailAddress(String address, String displayName) to throw exception. Specifically, it sometimes adding an extra “.” after SMTP address.

You can reproduce result by creating MailAddress with any email address ending with “.”, such as:

var address = new Aspose.Email.MailAddress("x@x.com.", "display name");

A good & simple solution would be to have option to disable email validation.

@ast3,

I have observed your requirements and suggestion. An issue with ID EMAILNET-39638 has been created 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.

Seeing the same issue in Aspose.Email for .NET 23.4 version too.
Is this issue fixed?

Hello @Srinidhi,

Could you provide a detailed description of your problem with a code sample and a message file so that we could investigate your issue individually and provide our feedback?

Thank you.

Hi @margarita.samodurova,
It is the same exact issue pointed above.
The mailbox address for cc sent by Microsoft is
of type cc: /o=exchangelabs/ou=exchange administrative group which is not exactly in the standard email address format.

For example:

var address = new Aspose.Email.MailAddress("/o=exchangelabs/ou=exchange administrative group", “”)

Is there a way we can use the above cc address to create a Aspose.Email.MailAddress ?

Thanks,
Srinidhi

Hi @Srinidhi,

The Aspose.Email has overloaded MailAddress(string, bool) constructor to disable email validation.

Please, see the following reference:

Hi @margarita.samodurova,

It’s failing still.

Please try ,
var address = new Aspose.Email.MailAddress("/o=exchangelabs/ou=exchange administrative group", false)

Thanks,
Srinidhi

Hi @Srinidhi,

If you take a closer look at the reference, it says: " if set to true then SMTP check will be omitted."

So, please, try:

var address = new Aspose.Email.MailAddress("/o=exchangelabs/ou=exchange administrative group", true);

and share your feedback.

Thanks.