Sample Code Please: Find Link and click on it: WebPage

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Sample Code Please: Find Link and click on it: WebPage

Post by adivarup » Mon Mar 27, 2006 11:33 pm

Is it possilbe for someone to display some sample code for me?

I want to automate the task of printing invoices that are sent to me via email.

I know how to log into my email account, but want I do not know how to do is to click on a specfic email with a certain topic, then open that email and click on a link in that email.

When someone buys one of my products, I get an email and I usually go to that email, click on the link in that email and I print the inovice as that link takes me directly to a invoice page.

The subject of the email goes like this
"New Order ID:34352234xxxx"

Then I open up the email, and there is a link that says
"To New Order ID:xxxxxxxxxx click here"

Can someone please show me a sample script that will look for the subject "New Order ID"

and click on the link "To New Order ID"

Thank you!
________
TF101
Last edited by adivarup on Wed Feb 02, 2011 12:34 pm, edited 1 time in total.

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Tue Mar 28, 2006 4:29 am

This may not be exactly what you are asking for, but.....

I have scripts that take orders from websites for customers by
1. creating an email inbox like [email protected],
2. use RetrievePOP3 to pull the order files (in .txt format) to a folder.

You could then write a script to strip out the link, Open IE to that link and print your invoice.

OR you could create a rule in your email system to sort out any email with "ORDER ID" in the subject line to a different folder than your other emails. Then write the script to strip out the link you need to open.

These methods would be easier than trying to click-through your email interface to pick out just the emails you need to process.

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Tue Mar 28, 2006 5:26 am

Thanks for your response.

Yes, its sounds like your way will be easier. But I still have the issue of picking pulling the link from the email and clicking on it to open up to a new window.

I would still like to know how to make it work for the method I have in mind. Your idea is very helpful but understanding this task helps me with a a few other things. :-)

thanks
________
WEB SHOWS
Last edited by adivarup on Sat Aug 13, 2011 3:07 pm, edited 1 time in total.

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Tue Mar 28, 2006 6:30 pm

Hi,

If someone has a quick second, would you mind helping me on this.

Thank you!
________
BMW 802 history
Last edited by adivarup on Wed Feb 02, 2011 12:35 pm, edited 1 time in total.

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Mar 28, 2006 6:34 pm

What is your Email client?

Can you view the raw message?

Opening the email will not provide you with the "link" ("To New Order ID:xxxxxxxxxx click here"). You need to view the equivalent of the html source. Again this depends upon your email client.

Later,
Dick

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Tue Mar 28, 2006 8:01 pm

Hi, thanks for your response.

My client? I am using a webmail interface, like hotmail.
________
hot box vape
Last edited by adivarup on Wed Feb 02, 2011 12:36 pm, edited 1 time in total.

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Mar 28, 2006 9:15 pm

Sorry, I'd help if I could but I have no knowledge in that realm. I've never used a web based email so I set up an account a few minutes ago and sent myself a message, viewing source shows nothing and beyond manipulating text (which doesn't appear to be possible) I don't know how to begin.

Seems like WebRecorder might be an option though I've never used that either so again I'm no help.

Can you set up pop3 to download from your web based email? It appears that google mail has pop3 capabilities.

Good luck,
Dick

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Tue Mar 28, 2006 9:50 pm

JRL

Do you have some sample code you can share with me where you are reading your pop3 email, going to a message and clicking on the hyperlink in that message. I can change over to pop3 if that is the case.
________
Ferrari P specifications
Last edited by adivarup on Wed Feb 02, 2011 12:36 pm, edited 1 time in total.

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Mar 28, 2006 11:37 pm

OK, this is quick and dirty and no guarantees that the code will be correct, I have not tested it.

I use Pegasus Mail as my POP3 client. When I receive a new email message it not only shows up in the client, it shows up in C:\PMAIL\MAIL\DICK as a file named xxxxxxxx.CNM. You could also use Macro Scheduler's POP3 client to create files with names of your choice in a directory of your choice as Paul (SkunkWorks) pointed out earlier. You can then parse the txt in the POP3 received message to acquire your URL. Here is a sample email that I sent to myself with your "To New Order ID:1234567890 click here" text as the "link" to the mjtnet URL. In the email client it would show up as:

To New Order ID:1234567890 click here

however the raw file looks like this:


Return-Path:
Received: from [192.168.0.137]
by mail.myserver.com (8.9.3/8.9.2) with ESMTP id RAA24435
for ; Tue, 28 Mar 2006 17:03:48 -0600
From: "My Name"
To: myname(at)myserver.com
Date: Tue, 28 Mar 2006 15:58:25 -0600
MIME-Version: 1.0
Subject: URL test
Reply-to: myname(at)myserver.com
Message-ID:
Priority: normal
X-mailer: Pegasus Mail for Windows (4.31)
Content-type: text/html; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body
X-PM-PLACEHOLDER: .








To New Order ID:1234567890 click here




What I would do next is loop through and read each new .CNM file, looking for the line that contains the text "To New Order ID:1234567890 click here". this line will also contain the URL. Since the order number will be different each time, I'd limit the search to "To New Order ID:" One possible problem would be if this string shows up in the subject line as well as the body of the message. I'm not going to worry about that for this example.

The code for one iteration could look something like this: (as I said this is untested)


ReadFile>C:\pmail\mail\dick\xxxxxxxx.CNM,filetext
Separate>filetext,%CRLF%,var

Let>k=0
Repeat>k
add>k,1
Let>line=var_%k%
separate>line,To New Order ID:,linetest
If>%linetest_count%>1
Separate>line,",URLfind
Let>kk=0
Repeat>kk
add>kk,1
Let>URL=URLfind_%kk%
Midstr>URL,1,4,test
If>test=http,found
Until>kk,URLfind_count
EndIF
Until>k,var_count

Label>found

MDL>do something with variable %URL%


See help for HTTPRequest> to see how to use the variable "URL" to call the website.

Hope this is useful,
Dick
Last edited by JRL on Wed Mar 29, 2006 2:33 pm, edited 1 time in total.

adivarup
Junior Coder
Posts: 36
Joined: Tue Mar 21, 2006 10:04 pm

Post by adivarup » Wed Mar 29, 2006 12:54 am

Thanks for the response on this.

I will play around with it...

Is there a way to find a Hyperlink on a page by partial name then then click on it?
________
medical marijuana patient

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts