We are using Email - Exchange Managed API object to communicate with our Outlook mail box. Configuration is working fine but while reading emails by action "List messages", getting an error "ERROR: Internal : Could not execute code stage because exception thrown by code stage: The request failed. The remote name could not be resolved: 'outlook.office365.com'". This is happening in our Production BP environment.
If we trigger the same process into same Robot VDI from Development environment, everything is working fine. I moved the Email Exchange object again to production thought if any sync issue but still we face the same issue.
Can anybody help us to know what would be the reason for this issue? Please let us know if any set up has to be done for Production BP before using Email - Exchange Managed API.
This is the code of List Messages
InitExchangeService();
// Bind the folder to the service object.
Folder TargetFolder;
if (String.IsNullOrWhiteSpace(FolderName))
{
TargetFolder = Folder.Bind(service, WellKnownFolderName.Inbox);
}
else {
FolderId FID = getFolderIDByName(FolderName, service);
if (FID == null) {
throw new Exception("Foldername invalid. Please provide a valid mail folder to search in.");
}
TargetFolder = Folder.Bind(service, FID);
}
// The search filter to get unread email.
//SearchFilter unreadsf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
SearchFilter unreadsf = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false);
// The view to return
ItemView view;
if (MaxNumberOfResults == 0)
{
view = new ItemView(int.MaxValue);
}
else {
view = new ItemView(Convert.ToInt32(MaxNumberOfResults));
}
view.PropertySet = new PropertySet(BasePropertySet.IdOnly, EmailMessageSchema.Subject, EmailMessageSchema.From, EmailMessageSchema.DateTimeSent);
// Fire the query for the unread items.
// This method call results in a FindItem call to EWS.
FindItemsResults<Item> findResults;
if (ShowOnlyUnreadMessages)
{
findResults = service.FindItems(TargetFolder.Id, unreadsf, view);
}
else {
findResults = service.FindItems(TargetFolder.Id, view);
}
MoreAvailable = findResults.MoreAvailable;
Results = new DataTable();
Results.Columns.Add("MessageID", typeof(string));
Results.Columns.Add("From", typeof(string));
Results.Columns.Add("Subject", typeof(string));
Results.Columns.Add("DateTimeSent", typeof(DateTime));
foreach(Item i in findResults){
Results.Rows.Add(i.Id, ((EmailMessage)i).From.Name, i.Subject, i.DateTimeSent);
}
------------------------------
Ashis Kumar Ray
RPA Developer
------------------------------