Jump to content

Workflow to pass an image to a snippet to use as an email signature


Recommended Posts

Hi,

 

I'm using the following script in a workflow to paste an image into a snippet for an email signature, but all it's pasting is the shared prefix ";" and keyword "emailsignew".
 

set filePath to "/Users/xyz/Documents/folder/emailbanner.jpg" 
set the clipboard to POSIX file (POSIX path of ((POSIX file (/Users/xyz/Documents/folder/emailbanner.jpg)) as alias))

 

Any help would be appreciated.

Link to comment

Hi @SteveG, welcome to the forum.

 

35 minutes ago, SteveG said:

Any help would be appreciated.

 

It's really hard to say without having the workflow you're talking about. Could you upload it somewhere (Dropbox?) and post a link?

 

36 minutes ago, SteveG said:

paste an image into a snippet

 

What do you mean? Snippets can't contain images.

Link to comment

I've had a closer look, and there's an error in your code (which I corrected when changing the image path). You didn't quote the path on the second line. The correct code should be:

 

set filePath to "/Users/stephengreenhalgh/Documents/Guardian/emailbanner.jpg"
set the clipboard to POSIX file ((POSIX path of filePath) as alias)

 

You should have been getting an error in Alfred's debugger telling you the code was invalid.

Link to comment

I've tried your code second line and mine, and both return the same - in the snippet I use ;emailsignew to call the image which should be on the clipboard and my signature just shows - 

 

"Kind regards

 

Steve G

 

;emailsignew

 

discliamer text."

 

If I type ;emailsignew anywhere I just get the contents of the clipboard, which is never the stored image.

Edited by SteveG
Link to comment
3 hours ago, SteveG said:

You can see that on the original comment of this post. 

 

It's in brackets, not quotation marks. String literals must be in quotation marks.

 

3 hours ago, SteveG said:

I've tried your code second line and mine

 

What does the debugger say? The filepath might be incorrect.

Link to comment

The debugger doesn't look like it's picking anything up. Is there a way to run it, or does it just highlight errors if there are any?

 

I've copied the file path from finder. I wondered if iCloud was causing an issue and moved the image to my local user folder, but I'm still getting the same issue in that the signature is coming out as -

 

kind regards

 

Steve G

 

;emailsignew 

 

disclaimer.

Link to comment

The error must be in the second line because when I type in the workflow keyword and shared prefix it returns the part in quotes

 

set filePath to "/Users/stephengreenhalgh/emailbanner.jpg"
set the clipboard to POSIX file ((POSIX path of "/Users/stephengreenhalgh/emailbanner.jpg") as alias)

 

Link to comment

I'm getting the following error from the debugger - 

 

[14:17:08.247] ERROR: Expand Image[Run Script] /Users/stephengreenhalgh/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/ED03D6FF-F57C-4974-8F9D-A59D80E7E5C7:156:161: execution error: Can’t make "/Users/stephengreenhalgh/emailbanner.jpg" into type alias. (-1700)

 

Link to comment

Lol, yes I'm sure the file exists.

 

I've tried that and it runs without errors in the debugger, but doesn't paste the image in mail. It does work in other apps though, so unless it's fixed in either an Apple or Alfred update I guess it just won't work.

 

With regards to running a snippet that calls the image paste workflow, I've never managed to get that to paste the clipboard. When I say "returns" I mean that the snippet calls the workflow because I'm using ;emailsignew in the snippet, but it just shows the text ";emailsignew" instead of pasting the clipboard.

Link to comment
1 hour ago, SteveG said:

Lol, yes I'm sure the file exists.

 

Your workflow works for me. The only thing I had to change was the path. So it's the obvious place to double-check.

 

1 hour ago, SteveG said:

It does work in other apps though

 

Well there's your clue that the problem is at Mail's end.

 

Have you checked that Alfred has all necessary permissions?

 

Other than that, you can try adding delays to the script. Increasing the "Restore after" period in Alfred Preferences > Features > Snippts > Auto Expansion Options often helps when snippets aren't working in a particular application.

 

You could also try adding delay 0.5 to the top of your AppleScript to give Alfred time to clear the snippet trigger from Mail.

 

Link to comment

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...