Accessing Exchange E-mails on Office 365

Hi All,

we are currently undergoing an upgrade to Office 365 from the previous Office 2010. Until now I have been able to receive and send E-mails via the exchange by specifying the exchange server address, supplying the domain, Password and User.

As part of the upgrade we need to perform testing to ensure everything works as expected and part of that testing is that the robot will continue to access E-mails ok. We performed Pre-Migration tests and everything worked as expected, I was able to receive all e-mails in the Robots Inbox and then send a test E-mail. We then migrated that account and since migration I have been unable to receive any E-mails, however I can still send.

We have been provided with a new Server address, and the only other change is that in order to authenticate the user now needs to be Robot.One@uk.company.com whereas previously it was simply Robot.One. It seems to authenticate fine as If this is not specified it throws a specific unauthorised user Error. However, I am now get a Aggregated Exception, the crux of which seems to be that it doesnt recognise the E-mail format as being a correct format

System.AggregateException: One or more errors occurred. —> UiPath.Mail.ExchangeException: The specified string is not in the form required for an e-mail address. —> System.FormatException: The specified string is not in the form required for an e-mail address.

Being as the activity doesn’t ask explicitly for an E-mail address, I assume that it is constructing one based on the User ID? Could this be causing it to build incorrectly as we now have to specify the entire E-mail in order to authenticate?

Any Help would be much appreciated.
Thanks
Pete

@ovi can you confirm on this one? my guess is there’s something it doesn’t like about the uk.company.com (i.e. two dots).

In order to confirm, we’ll need Studio version and UiPath.Mail.Activities package version please.

Hi @ovi

Unfortunately we’re a bit out of date as it stands whilst we get full infrastructure implemented, however, Studio version is 2016.2.6232
UIPath.Mail.Activities was 1.1.6277.16049, however I just updated to 1.1.6562.21018 and still have the issue.

Interestingly, it only seems to be when trying to use Get Exchange Mail Message. Using the same Properties on Send Exchange Mail Message works fine with no errors and The Sent E-mail is received.

Thanks

Hi Pete,

My first thought was that you didn’t set right the Properties in the Exchange activity, but since it works with Send so it should with Get.

I’ll send this to be tested and get back to you when i have an answer. Thanks!

Thanks Ovi,

I’ve attached a screenshot with my current properties set up. I’ve tried all exchange versions, I’ve tried with and without the Domain, and all manner of combinations within the options.
As you can see the user is set as Robot.Three@uk.*******.com Previously before the O365 migration this was just Robot.Three which if used now provides an authentication error.

Below is the exceptions that are thrown.

Main has thrown an exception
Message: One or more errors occurred.
Source: Get Exchange Mail Messages
Exception Type: AggregateException
System.AggregateException: One or more errors occurred. —> UiPath.Mail.ExchangeException: The specified string is not in the form required for an e-mail address. —> System.FormatException: The specified string is not in the form required for an e-mail address.
at System.Net.Mail.MailAddressParser.ParseAddress(String data, Boolean expectMultipleAddresses, Int32& index)
at System.Net.Mail.MailAddressParser.ParseAddress(String data)
at System.Net.Mail.MailAddress…ctor(String address, String displayName, Encoding displayNameEncoding)
at System.Net.Mail.MailAddress…ctor(String address, String displayName)
at UiPath.Mail.ExhangeMail.CreateMailMessageFromEmailMessage(EmailMessage mimemessage, Boolean saveattchements)
— End of inner exception stack trace —
at UiPath.Mail.ExhangeMail.CreateMailMessageFromEmailMessage(EmailMessage mimemessage, Boolean saveattchements)
at UiPath.Mail.Exchange.Activities.GetExchangeMailMessages.GetMessages(ExchangeService service, String fromFolder, String sharedMailbox, Int32 count, CancellationToken cancellationToken)
— End of inner exception stack trace —
at UiPath.Mail.Exchange.Activities.ExchangeActivity`1.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
—> (Inner Exception #0) UiPath.Mail.ExchangeException: The specified string is not in the form required for an e-mail address. —> System.FormatException: The specified string is not in the form required for an e-mail address.
at System.Net.Mail.MailAddressParser.ParseAddress(String data, Boolean expectMultipleAddresses, Int32& index)
at System.Net.Mail.MailAddressParser.ParseAddress(String data)
at System.Net.Mail.MailAddress…ctor(String address, String displayName, Encoding displayNameEncoding)
at System.Net.Mail.MailAddress…ctor(String address, String displayName)
at UiPath.Mail.ExhangeMail.CreateMailMessageFromEmailMessage(EmailMessage mimemessage, Boolean saveattchements)
— End of inner exception stack trace —
at UiPath.Mail.ExhangeMail.CreateMailMessageFromEmailMessage(EmailMessage mimemessage, Boolean saveattchements)
at UiPath.Mail.Exchange.Activities.GetExchangeMailMessages.GetMessages(ExchangeService service, String fromFolder, String sharedMailbox, Int32 count, CancellationToken cancellationToken)<—
—> (Inner Exception #1) UiPath.Mail.ExchangeException: The specified string is not in the form required for an e-mail address. —> System.FormatException: The specified string is not in the form required for an e-mail address.
at System.Net.Mail.MailAddressParser.ParseAddress(String data, Boolean expectMultipleAddresses, Int32& index)
at System.Net.Mail.MailAddressParser.ParseAddress(String data)
at System.Net.Mail.MailAddress…ctor(String address, String displayName, Encoding displayNameEncoding)
at System.Net.Mail.MailAddress…ctor(String address, String displayName)
at UiPath.Mail.ExhangeMail.CreateMailMessageFromEmailMessage(EmailMessage mimemessage, Boolean saveattchements)
— End of inner exception stack trace —
at UiPath.Mail.ExhangeMail.CreateMailMessageFromEmailMessage(EmailMessage mimemessage, Boolean saveattchements)
at UiPath.Mail.Exchange.Activities.GetExchangeMailMessages.GetMessages(ExchangeService service, String fromFolder, String sharedMailbox, Int32 count, CancellationToken cancellationToken)<—

Could you please try with user Robot.Three@uk.*******.com in EmailAutoDiscover field?

Hi Ovi,

I also tried using the auto discover rather than the server directly, in this instance it throws the error “The Auto discover service couldn’t be located”

interesting, the actual e-mail address remains robot.three@*****.com it is just the authentication on the server where the uk. has been added. Regardless, I have tried both versions in the auto discover and it could not be located. Based on previous conversations with IT, I believe the auto discover was turned off whilst we are undergoing migration as it was causing issues between the on premise and cloud.

Thanks

1 Like

Hi @Pete.Darby,
What is the best mail activity to access office 365 mails?
Did your issue got resolved

Hi Sreekanth,

Issue still persists, although I believe its due to the username format that the company has adopted rather than anything specific to O365, I’m guessing under normal circumstances there would be no issue. Unfortunately our outlook is also tightly locked down, so whilst using the GetOutlook Mail activity works to a degree, all I’m then able to extract from it is the E-mail Subject and nothing else.

I would simply build a test case for each of the activities and trail them all to see which suits your use case best.

1 Like

hi @ovi,
I am facing with get mail activity using exchange service , we are not able to fetch the older email than current date in get email activity , can you please help us how to fetch the emails older than current date .
please guide us , if we are missing any thing …

Regards
Raj kumar

Hi @sreekanth,

Did you ever integrate mail activities with Office 365?

Thanks!

No @kellen.I’ve used Outlook

I tried this again recently after we upgraded to 2018.3 and after updating the mail activities to the latest and it seems to work getting e-mails from the exchange now. I’m unsure if this is due to any change on the UIPath side, or whether its simply because our Migration to O365 has finished and whether settings in the backend that we have no visibility of have changed…

Hello Pete , we are in the same situation now … Any suggestions you wanted to provide .

The Autodiscover service not located issue

@Syed_Pasha The error " The Autodiscover service couldn’t be located." appears when you have username and password configured while using automdiscover option. Remove values in username and password arguments and the error should go away.

I am fencing the same Issue

Send Exchange Mail Message: The request failed. The remote server returned an error: (401) Unauthorized.

I used Server: “https://outlook.office365.com/EWS/Exchange.asmx”
Password & User is correct

@all any solution to this ?

Any idea?

I got it resolved. it needs to have admin acess if using exchange server