Jump to content
ixium

Email Forward to specific address + No Signature

Recommended Posts

Good Morning, I have been working on my workflow recently with trello and a co worker, I have to constantly forward emails to them, I have two instances of my hotkey forward, which forwards the selected email to my coworker and one that forwards the message to my trello board to keep it as a to do item.

 

I have a workflow I made with some apple script I found that forwards the email in an ok fashion (not great) but the problem is it adds my signature so my trello board is now filled with my company logo, not very pretty. I have turned off the setting for adding the signature to quoted text but it still pops up in the forward.

 

So my question is, can someone give me a more elegant way to do this, or just help me tweak my code to make sure no signature is selected. I have created a blank signature title "none" I just dont know how to select it.

 

here is the code I am using now

___________________________________________________

 

on alfred_script(q)
  set myComment to "xxxx@boards.trello.com"
set theName to "Some name"
set theAddress to "Some email address"
 
try
    set the clipboard to myComment
    tell application "Mail"
        set theSelection to selection
        set theForwardedMessage to forward (item 1 of theSelection) with opening window
        tell theForwardedMessage
            make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
        end tell
        activate
        tell application "System Events" to keystroke "v" using {command down}
        delay 1
        send theForwardedMessage
    end tell
end try
end alfred_script

 

 

___________________________________________________

 

thank you so much for anyone that can help!

Share this post


Link to post

Mail Act-On (a mail plug-in) rules can strip a signature.  I believe they use AppleScript (sorry on my phone right now...) so it should be possible.

Share this post


Link to post

It looks to me like this is a bug in AppleScript (on Sierra at least).  I tried a handful of Mail signature creation scripts and experimented with yours and none of them are working.  See also https://gist.github.com/Moligaloo/3850710 .  With Sal gone I fear it may never get fixed.

 

But....Mail Act-On Outbox rules do work, so presumably they're accessing the signature some other way.  It's $30 but if you work with a lot of email it's worth it IMHO.

Edited by dfay

Share this post


Link to post

Thank you for looking into that for me, I dont know enough about this stuff to implement it corectly, where would I put this code in my code?

 

new code

 

try 
set message signature of new_message to signature mySignature 

on error --BUG SIERRA 

tell application "Mail" to activate 
tell application "System Events" 
tell process "Mail" 
click pop up button 1 of window 1 
delay 0.1 
keystroke "g" --put here the first letter of the name of your signature 
delay 0.1 
keystroke return 
delay 0.1 
end tell 
end tell 


end try 

 

 

 

My code

 

on alfred_script(q)
  set myComment to "xxxx@boards.trello.com"
set theName to "Some name"
set theAddress to "Some email address"
 
try
    set the clipboard to myComment
    tell application "Mail"
        set theSelection to selection
        set theForwardedMessage to forward (item 1 of theSelection) with opening window
        tell theForwardedMessage
            make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
        end tell
        activate
        tell application "System Events" to keystroke "v" using {command down}
        delay 1
        send theForwardedMessage
    end tell
end try
end alfred_script

Share this post


Link to post
set myComment to "xxxx@boards.trello.com"
set theName to "Some name"
set theAddress to "Some email address"
set mySignature to "blank"


try
	set the clipboard to myComment
	tell application "Mail"
		set theSelection to selection
		set theForwardedMessage to forward (item 1 of theSelection) with opening window
		tell theForwardedMessage
			make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
		end tell
		activate
		tell application "System Events" to keystroke "v" using {command down}
		delay 1
		
		try
			set message signature of theForwardedMessage to signature mySignature
			
		on error --BUG SIERRA 
			
			tell application "Mail" to activate
			tell application "System Events"
				tell process "Mail"
					click pop up button 4 of window 1
					delay 0.1
					keystroke "b" --put here the first letter of the name of your signature 
					delay 0.1
					keystroke return
					delay 0.1
				end tell
			end tell
			
			
		end try
		
		-- send theForwardedMessage
	end tell
end try

this worked for me (commented out the send for testing)

 

this requires that you have a signature called "blank" that's active in the sending account

Edited by dfay

Share this post


Link to post

Thank you so much for your help so far, I am having no luck with this, I have set up blank signatures on all accounts, now when I hit the hotkey it puts the correct address in the sender but then just sits there and does not continue forward :( any ideas?

Share this post


Link to post

Nothing coming up in there after trying it, it inputs the right email address but then does nothing, you confirmed this working on your end?

 

Share this post


Link to post

Hmm.  I did the 10.12.4 upgrade last night and now it needs to click pop up button 5 instead of 4 ... don't notice what changed in the UI but something must have.  You may need to do some trial and error to get the correct pop up button # -- I use Mail Add-On and MailTags which modify the Mail window, so the # of the button may be different in your case.  Such are the perils of being forced to use UI scripting.

 

It may be an issue with the way Alfred calls scripts, and the handling of subprocesses / System Events therein.  It's working for me with a Run Script > osascript (AS) > input as {query} object in the workflow.

 

But...I just checked and it works as Run NSApplescript as well.

 

Here's the exact code I am using with Run NSApplescript:

 

on alfred_script(q)
  set theQuery to q

set myComment to "xxxx@boards.trello.com"
set theName to "Some name"
set theAddress to "Some email address"
set mySignature to "blank"


try
	set the clipboard to myComment
	tell application "Mail"
		set theSelection to selection
		set theForwardedMessage to forward (item 1 of theSelection) with opening window
		tell theForwardedMessage
			make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
		end tell
		activate
		tell application "System Events" to keystroke "v" using {command down}
		delay 1
		
		try
			set message signature of theForwardedMessage to signature mySignature
			
		on error --BUG SIERRA 
			
			tell application "Mail" to activate
			tell application "System Events"
				tell process "Mail"
					click pop up button 5 of window 1
					delay 0.1
					keystroke "b" --put here the first letter of the name of your signature 
					delay 0.1
					keystroke return
					delay 0.1
				end tell
			end tell
			
			
		end try
		
		-- send theForwardedMessage
	end tell
end try
  return theQuery
end alfred_script

 

Edited by dfay

Share this post


Link to post

Still having no luck with this, no errors kicking out, I dont know how to find the popup window is is supposed to be clicking, I do have the accessibility inspector but I dont know how to use it to find the numbers I need

 

I dont want to keep bothering you with this, so thank you so much for your help so far, I will just have to manualy delete the signature for now, not too big of a deal

 

Thank you again for all the help youve put into this over the past few days!

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...