Jump to content

Use case in search of a workflow


Recommended Posts

Posted

All -- I'm in search of a workflow that addresses a common use case for me. The situation is simple. I'm browsing the web and want to send a page I find to someone via email. 

 

What I'd like is to open a new Mail.app email window with a copy of the URL in the body of the message. 

 

Sounds so simple that I'm embarrassed I don't know how to build it myself yet.

 

Thanks in advance for your help.

 

-- Robert

 

Posted

All -- I'm in search of a workflow that addresses a common use case for me. The situation is simple. I'm browsing the web and want to send a page I find to someone via email. 

 

What I'd like is to open a new Mail.app email window with a copy of the URL in the body of the message. 

 

Sounds so simple that I'm embarrassed I don't know how to build it myself yet.

 

Thanks in advance for your help.

 

-- Robert

 

So, the real question is, when you say you want someone to "help", are you wanting someone else to create it for you or, are you wanting someone to help you learn how to create it and you make it? This one is actually pretty easy to do. I'd be happy to help either.

Posted

So, the real question is, when you say you want someone to "help", are you wanting someone else to create it for you or, are you wanting someone to help you learn how to create it and you make it? This one is actually pretty easy to do. I'd be happy to help either.

 

I would love to know how to build it myself, thanks! 

 

-- Robert

Posted

I would love to know how to build it myself, thanks! 

 

-- Robert

 

Ok, so this will require a script and a hotkey (could also be a keyword, just depends on your preference). You have two main things to accomplish. First, you'll need to get the current URL from your browser, then create a new mail message with that url in the message body.

 

1. So, create a new Workflow. Add your hotkey (or keyword) and configure it accordingly.

2. Next, add a Run Script item. This will be where we grab the current URL. Provided from this thread you could use the following code to grab the current URL fro your browser.

tell application "System Events"
	set myApp to name of first application process whose frontmost is true
	if myApp is "Google Chrome" then
		tell application "Google Chrome" to return URL of active tab of front window
	else if myApp is "Opera" then
		tell application "Opera" to return URL of front document
	else if myApp is "Safari" then
		tell application "Safari" to return URL of front document
	else if myApp is "Firefox" then
		tell application "System Events"
			keystroke "l" using command down
			keystroke "c" using command down
		end tell
		delay 0.5
		return the clipboard
	else
		return
	end if
end tell

Don't forget in this run script item to set the language to /usr/bin/osascript. Paste in the necessary code from the mentioned link.

3. Now, all of these conditionals have a "return" that will return the value. We don't want that, so you'll need to modify them to set a variable to that value. Then, at the very end of the AppleScript code, you'll add something new..

tell application "Mail"
  activate
  set theMessage to make new outgoing message with properties {content: theBody, visible:true}
end tell

theBody would be a variable that would be the URL from the previous code. This code only works with Mail.app. If you use an alternate mail application, we can do it another way to make it more generic but it requires an extra step to make it work properly.

 

Tinker around with that, if you have issues, let me know and I'll help you figure it out.

 

Good luck!

Posted

BRILL-I-ANT!

 

You've taught me to fish, here. I am really grateful. Works like a champ. Thank you!

 

-- Robert

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
×
×
  • Create New...