Jump to content

Applescript for sending selection as new Mail


gurth4ng
 Share

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

Link to comment
Share on other sites

  • 4 months later...

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

Link to comment
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 :)

Link to comment
Share on other sites

 Share

×
×
  • Create New...