How to extract email from inspect element href

I am trying to extract email from the below href element

javascript:openContactMe(‘https://www.mlsli.com/Content/Forms/ContactMe.aspx?listingagentid=18786389&agentemailaddress=rahuljaggi@me.com&subject=Inquiry:%20Listing%20No.%203213038&FormID=2&AgentFlg=1&BRListingFlg=0&ListingSourceID=436&ListingID=295840218&WebsiteID=0&IsWebsite=0&IsPrimary=0’);

i tried to extract using the screen shot but does not seem to be working.

Thank you for the help in advance.

Hello,

pattern = "agentemailaddress=(?<email>.+?)&"
email = Regex.Match(sample, pattern).Groups("email").ToString

EDIT:

You can look at what’s below (I didn’t test it).

myUri = New Uri("https://www.mlsli.com/Content/Forms/ContactMe.aspx?listingagentid=18786389&agentemailaddress=rahuljaggi@me.com&subject=Inquiry:%20Listing%20No.%203213038&FormID=2&AgentFlg=1&BRListingFlg=0&ListingSourceID=436&ListingID=295840218&WebsiteID=0&IsWebsite=0&IsPrimary=0")
email = HttpUtility.ParseQueryString(myUri.Query).Get("agentemailaddress")

Did you mean URL?

Uri, that’s not a typo. An Url is a case of Uri.

i apologize.i am a new to uipath. This is way over my head at the moment. Can you please provide some detailed explanation as to what to do? Thank you for your help. Much appreciated.

no problem but I don’t have UiPath on this computer.

Each line is an Assign activity and the left side member of the equality is a String variable.

You can then use your write line activity with email variable.

This worked on my test run. Thank you much.

1 Like

Michael, i am now getting the error “HttpUtility is not declared, It may be inaccessible due to its protection level.”

Thanks, Richy.

Hi,

import System.Web

I did but still does not seem to be working.

@loginerror

Hello @richygeorge

OK, I have the same problem in UiPath. Actually, when dealing with URL, I use Flurl library. You can add it to your dependencies from Manage Packages (see screenshot) then use the following lines

Assign (type Flurl.Url)
myUrl = New Flurl.Url("https://www.mlsli.com/Content/Forms/ContactMe.aspx?listingagentid=18786389&agentemailaddress=rahuljaggi@me.com&subject=Inquiry:%20Listing%20No.%203213038&FormID=2&AgentFlg=1&BRListingFlg=0&ListingSourceID=436&ListingID=295840218&WebsiteID=0&IsWebsite=0&IsPrimary=0")

Assign (String)
email = myUri.QueryParams("agentemailaddress").ToString