5 Replies Latest reply: Dec 7, 2009 8:37 PM by Martin R. Lerch
Martin R. Lerch Level 1 Level 1
Hello,

Not sure if I am posting this at the right spot, but I would need some assistance. I am trying to write an Automator Workflow application. The purpose for this application is to:
1. Drag one or more attachments on the application/droplet icon
2. Automator workflow creates a new mail message in Mail with the attached items already addressed and ready to go to

I setup the following Workflow inside Automator:
1. New Mail Message
2. Add Attachments to Front Message

So this is all working just fine. Now I would like to add a step in between of type "Run AppleScript". In this "Run AppleScript" action I have the following code:

on run {input, parameters}
tell application "Mail"
set the message signature of input to signature "My Signature Name"
end tell
return input
end run

So my workflow looks now like this:
1. New Mail Message
2. Run AppleScript
3. Add Attachments to Front Message

I am getting the following error:

Can’t make «class situ» "My Signature Name" of application "Mail" into the expected type.

So, in essence I am trying to select a signature for that particular new mail message in this workflow. And that does not work. Any help would be appreciated.

Martin

MacBook Pro 17" 2.33GHz, Mac OS X (10.6.2)
Solved by V.K. on Dec 7, 2009 8:05 PM Solved
first, you don't need the extra action to add attachments. if you drop some items on the saved application they will be passed to the "new Mail message" action as input and will be added as attachments. also, in my testing it seems that the processes of attaching the attachments seem to bump against the process of adding the signature. it get the same result as you originally but if I add a delay to the run applescript action then it works as it should so try

1. new mail message.
2. run applescript

on run {input, parameters}
delay 1
tell application "Mail"

set the message signature of (item 1 of input) to signature "My Signature Name"
end tell
return input
end run

Reply by Barney-15E on Dec 7, 2009 7:29 PM Helpful
Change it to
tell application "Mail"
set the message signature of item 1 of input to signature "My Signature Name"
end tell
The result from the previous action is an applescript list. It only contains one item, but it is a list so you must tell it to get item 1 of the list.
Reply by V.K. on Dec 7, 2009 7:25 PM Helpful
change the applescript action as follows


on run {input, parameters}
tell application "Mail"
set the message signature of (item 1 of input) to signature "My Signature Name"
end tell
return input
end run


see if it works now.

All replies

  • V.K. Level 9 Level 9
    change the applescript action as follows


    on run {input, parameters}
    tell application "Mail"
    set the message signature of (item 1 of input) to signature "My Signature Name"
    end tell
    return input
    end run


    see if it works now.
  • Barney-15E Level 8 Level 8
    Change it to
    tell application "Mail"
    set the message signature of item 1 of input to signature "My Signature Name"
    end tell
    The result from the previous action is an applescript list. It only contains one item, but it is a list so you must tell it to get item 1 of the list.
  • Martin R. Lerch Level 1 Level 1
    V.K. thanks for your swift reply. So I made the changes per your instructions. I ran the "Application" inside Automator and it works. The mail message is created, then the AppleScript runs fine and selects the correct signature, and the attachments action will not work inside Automator anyway. So I thought it was solved.

    Now I saved the workflow application and dragged 2 attachments on the Workflow application icon and the following happens:
    - mail is created
    - items are attached
    - signature still set to None.

    Then I tried changing the order inside the Automator workflow to:
    - New Mail Message
    - Add Attachments to Front Message
    - Run AppleScript

    But that didn't work either. No signature change. Any other suggestion?
  • V.K. Level 9 Level 9
    first, you don't need the extra action to add attachments. if you drop some items on the saved application they will be passed to the "new Mail message" action as input and will be added as attachments. also, in my testing it seems that the processes of attaching the attachments seem to bump against the process of adding the signature. it get the same result as you originally but if I add a delay to the run applescript action then it works as it should so try

    1. new mail message.
    2. run applescript

    on run {input, parameters}
    delay 1
    tell application "Mail"

    set the message signature of (item 1 of input) to signature "My Signature Name"
    end tell
    return input
    end run

  • Martin R. Lerch Level 1 Level 1
    Hello V.K.,

    Thanks again. This time it worked. I'll mark this one as solved.

    Martin