Grabbing text from an email and pasting into another application

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
Louis335
Newbie
Posts: 3
Joined: Mon Feb 17, 2020 2:45 pm

Grabbing text from an email and pasting into another application

Post by Louis335 » Mon Feb 17, 2020 2:55 pm

Dear forum,
new to Macro Scheduler.
Trying to tread a path than must have been trodden before, ideally looking for an existing script that I can modify.
Need to:
1. Check each new incoming email to a specific email address
2. Scan that email for a specific line of text containing a user MachineID number, which would always be pre-fixed with the text 'MachineID = '
3. Past that machine ID number into another windows application.
4. Ensure that this only happens for each new email, not repeatedly for the same email.

Need some pointers from a more experienced MS-er out there !
Many thanks,
Louis

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Grabbing text from an email and pasting into another application

Post by Grovkillen » Tue Feb 18, 2020 8:27 am

What do you have so far, in terms of code? What email client is used? Give more details!
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Grabbing text from an email and pasting into another application

Post by Dorian (MJT support) » Tue Feb 18, 2020 11:03 am

RetrievePOP3 could be your best way of achieving this.

I recommend something like this :
  • Create an email filter/rule, forwarding any emails you want to process to a new email address, solely used for this purpose.
  • Use RetrievePOP3 to check that email address.
  • Use Let>POP3_DELETE=1 so messages are deleted after being checked.
  • Use String Handling commands to extract the text you need.
  • ....Once you have the text extracted you can do whatever you wish with it.
Of course this can then be run on a schedule to check that email address as frequently as you like.
Yes, we have a Custom Scripting Service. Message me or go here

Louis335
Newbie
Posts: 3
Joined: Mon Feb 17, 2020 2:45 pm

Re: Grabbing text from an email and pasting into another application

Post by Louis335 » Tue Feb 18, 2020 4:24 pm

Thank you Dorian,
that's a great pointer to get me started.
One question for now, how can I ensure that RetrievePOP3 only retrieves the earliest email (in time received), rather than all emails on the mail server at that time ?
That way (I think) I can ensure that each email is dealt with individually, before deleting it, and waiting for the next one.
Many thanks,
Louis

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Grabbing text from an email and pasting into another application

Post by Dorian (MJT support) » Wed Feb 19, 2020 3:38 pm

You can't control that. RetrievePop3 will download whatever is there, and it will either delete none of them or all of them depending on your setting. So I suggest using a test email address first, which contains emails you send to it to test your script. Once you know for sure that it's working, either allow that email address to "go live", or start processing a different email address.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Grabbing text from an email and pasting into another application

Post by Marcus Tettmar » Wed Feb 19, 2020 5:49 pm

As Dorian says if it's a dedicated box you could set them to delete, so you know you're only getting new emails all the time. Otherwise you'd need to store the count somewhere. E.g. in an INI file. Then you can use that to determine which are new and which aren't (any after that count would be new).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Louis335
Newbie
Posts: 3
Joined: Mon Feb 17, 2020 2:45 pm

Re: Grabbing text from an email and pasting into another application

Post by Louis335 » Thu Feb 20, 2020 6:58 pm

Thanks guys, that clarifies.
A few days work at this, and it's proving to be a useful tool.

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