Jump to content
  • Announcements

    • Allan

      Forum Rules   04/13/2018

      Hello folks! As some things are being fixed, we'll keep you updated. Per hour the Forum Rules don't have a dedicated "Tab", so here is the place that we have our Rules back. New Users Lounge > [READ] - InsanelyMac Forum Rules - The InsanelyMac Staff Team. 
gurth4ng

Applescript for sending selection as new Mail

3 posts in this topic

Recommended Posts

Hello. What i'm trying to achieve is adding an option to Safari for getting the selected text and sending it to Mail as the content of a new email message, along with the website's url. The already available action "New Mail Message" is able to do half of what i'm asking: it can send my selection to Mail as the content of a new emal message, but nothing more. I'm trying to compose an Applescript to run from within my Automator Service, but i'm getting an error:

The action "Run AppleScript" encountered an error.

 

Any ideas?

 

Here is the script i'm using:

on run {input, parameters}

set myBodyText to value of variable "mySelection" of front workflow
set siteURL to value of variable "mySiteURL" of front workflow

tell application "Mail"
	make new outgoing message with properties {visible:true, subject:"Something Interesting", content:"" & siteURL & myBodyText}
end tell

return input
end run

 

And here is a screenshot of my Automator Workflow:

2qi2xom.jpg

Share this post


Link to post
Share on other sites

You find a resolution for this? I'm having the exact same issue.

 

 

 

Hello. What i'm trying to achieve is adding an option to Safari for getting the selected text and sending it to Mail as the content of a new email message, along with the website's url. The already available action "New Mail Message" is able to do half of what i'm asking: it can send my selection to Mail as the content of a new emal message, but nothing more. I'm trying to compose an Applescript to run from within my Automator Service, but i'm getting an error:

The action "Run AppleScript" encountered an error.

 

Any ideas?

 

Here is the script i'm using:

on run {input, parameters}

set myBodyText to value of variable "mySelection" of front workflow
set siteURL to value of variable "mySiteURL" of front workflow

tell application "Mail"
	make new outgoing message with properties {visible:true, subject:"Something Interesting", content:"" & siteURL & myBodyText}
end tell

return input
end run

 

And here is a screenshot of my Automator Workflow:

2qi2xom.jpg

Share this post


Link to post
Share on other sites
You find a resolution for this? I'm having the exact same issue.

 

I've gotten to a point where it works, but it doesnt work as i would like so i abandoned it. What i did, was use this following Applescript:

on run {input, parameters}
set selectedText to item 1 of input
tell application "Safari"
	tell document 1
		set pageURL to URL
	end tell
	tell window 1
		tell current tab
			set pageTitle to name
		end tell
	end tell
end tell
tell application "Mail"
	activate
	make new outgoing message with properties {visible:true, subject:"Αποστολή Άρθρου: " & pageTitle, content:"" & return & pageTitle & return & return & return & return & selectedText & return & return & return & return & return & return & pageURL}
end tell
end run

 

what it does, is:

it takes your selection from Safari

it takes the page's title and url

it create a new Mail message using the title as the msg's topic

it adds in the message body your selection, along with the page's url

 

While it works, the problem is that it doesnt add any images or formatting from the webpage, so it's only good to copy plain text. I guess there must be a way to fix this, but i got kinda tired with it to be honest.

 

If you find anything, please tell me :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

×