Jump to content

Applescript for sending selection as new Mail


  • Please log in to reply
2 replies to this topic

#1
gurth4ng

gurth4ng

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 2 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:
Posted Image

#2
Sphere777

Sphere777

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 1 posts
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:
Posted Image



#3
gurth4ng

gurth4ng

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 2 posts

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 tellend 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 :)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy