Open Outlook Email

Hi
I need to open an email of a particular subject and then click on the URL inside that email .
I have used Get outlook Mail message activity to get the top 30 emails then applied a For each loop adding condition as item.Subject.Contains(“SUBJECT”) but I am stuck as then condition of this For Each loop should open that email and then click on the hyperlink inside email .

Please suggest how can it be performed using Uipath

Thanks

Seeking help as what should be the sequence Activity of THEN part in FOR Each loop . How will uipath open a mail and then select the hyperlink inside it.

following is the logic

for each myMail in mails
if myMail.Subject.ToString.contains(“some string”)
if myMail.Body.ToString.contains(“http://”) or myMail.Body.ToString.contains(“https://”)
extract the url from the body
Openbrowser (url)
look for the stock etc…
end if
end if
end for

It should be get outlook mail. Check this https://activities.uipath.com/docs/get-outlook-mail-messages#section-output

Thanks, I saved the body in text file . The mail has various URL I want to select the URL in last field .
How should RegEx looks like in this scenario ?

hi @XYZ_1991

Use this sequence in the THEN part of your For Each Loop

  • Use Matches Activity
    Edit properties section as follows:
    Input - ‘item.Body.ToString’
    Pattern - "[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)"
    Result - Assign any suitable variableName

  • Use Open Browser Activity
    Edit properties section as follows:
    Url - variableName(0).value

This will open the first Url with pattern of http, https or a url without any protocol.

To open the last url in the body.
Get the count of IENumerable variableName string
Pass this count in place of ‘0’ in open browser.

Let me know if you are stuck again.

1 Like

It is giving the exception as below

Source: Open Browser

Message: Cannot communicate with Internet Explorer browser.

Exception Type: UiPath.Core.BrowserOperationException

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
UiPath.Core.BrowserOperationException: Cannot communicate with Internet Explorer browser. ----> System.Runtime.InteropServices.COMException: Cannot communicate with Internet Explorer browser.
at UiPath.UiBrowserClass.Open(String bstrURL, UiBrowserFlags flag)
at UiPath.Core.Browser.Open(String url, Boolean privateSession, Boolean headlessSession, Boolean defaultSession)
— End of inner ExceptionDetail stack trace —
at UiPath.Core.Activities.ScopeActivity.EndExecute(NativeActivityContext context, IAsyncResult result)
at UiPath.Core.Activities.AsyncNativeActivity.BookmarkResumptionCallback(NativeActivityContext context, Bookmark bookmark, Object value)
at System.Activities.Runtime.BookmarkCallbackWrapper.Invoke(NativeActivityContext context, Bookmark bookmark, Object value)
at System.Activities.Runtime.BookmarkWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

This arises many a time with IE.
This is a problem with browser settings or security settings.

You can try adding the URL you are hitting in the trusted list of IE.

Or atleast you can try with chrome or some other browser just to make sure your URL or the workflow is working.

You can also refer this Query raised earlier

.GetCount is not available as a Function of IEnumerable type variable we created .
URL : VariableName( ? ).Value : Not working

Use this to get count of IENumerable.
count - VariableName.count().tostring

Use this to Display the last Value: VariableName(VariableName.count()-1).Value

1 Like

This worked well , Thank You !

1 Like

If everything worked. can you mark my answer as solution :smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.