0
votes

I've done this in the past but for this particular example, the URL is not evident:
I have an email that arrives inviting the recipient to click on a link. If I hover over the link, I see the URL,

enter image description here

and, of course, if I click it, it opens on the browser, as expected. In the past, I would extract the contents of the email with AppleScript and the body of the message would show the URL.

use AppleScript version "2.4" -- Yosemite (10.10) or later

use scripting additions

set theMsg to MailLib's ExtractEmailMessages() set theMsg to item 1 of theMsg tell application "Mail" set BodyMessage to content of theMsg end tell

But this time BodyMessage only shows text and no URL. It only shows this:

Comments from the client (if any): Are you available to take this order?

Please note: If you click YES, the order will be AUTOMATICALLY assigned to you.  Please contact the client after.

YES, I WILL TAKE THIS ORDER 

Is there a way to extract the URL, so that I can open the link with AppleScript?

Thanks.

1

1 Answers

0
votes

In the Mail.app dictionary

  • The content property contains the plain text.
  • The source property contains all headers and the HTML text.

You have to extract the HTML text beginning with <html> or <!DOCTYPE from the source and use an HTML parser or text item delimiters to extract the information.