My preferred method of using scripts like this is to save the script to the Scripts folder in Library (probably in the Mail sub folder).

I also own Mail Act-On -- a wonderful utility for Mail users. I then set up a rule in Mail that will integrate with Mail Act-On (the Mail Act-On manual will tell you how to do this) and this script.

The result is that I can type a 'trigger' key (I use '/') in Mail, and then another key (I use "y" for Yojimbo), and the selected message (s) will be transferred to J=Yojimbo. Pretty darned elegant.



On Apr 8, 2007, at 11:13 AM, John Hawkins wrote:

I am a relatively new apple user, so please forgive my ignorance, but the recently posted 'script to pipe multiple Mail message to Yojimbo' is a script that I could really use. Can someone advise the best way to setup this script to run from mail?

Thanks in advance for any help and advice that you can provide.

Regards,
John.

On Apr 8, 2007, at 9:38 AM, Steven Samuels wrote:

I've completely re-organized the script. Now it will pipe multiple selected messages. I apologize for the multiple posts. Unless someone finds a mistake, this is the last version.

Steve

Script Follows the next line:
_____________________________________________________________________ ____________________________________________

(*
This script will:

1. Pipe selected messages from Apple Mail to Yojimbo notes
2. Put the date sent (yyyy/mm/dd) & name or address of sender or recipient into Comments
4. Add tags "email" and either "in" or "out"

After running the script, The Comments  will look like:

2007/04/08 <: NYTimes.com  (an incoming message)
or
2007/04/09 >: Sam          (an outgoing message)

Sorting on the Comments column will sort on date order.

Note: If an account has been deleted, all messages to and from it will be classified & tagged as incoming. To restore the proper classification, create a dummy version of the account and disable it. Only the email address need be correct; the server settings are irrelevant.

Credits:
Based on MailtoYojimbo Applescript by Jim Correia of Bare Bones Software Originally posted in the Yojimbo Talk Forum: http:// www.listsearch.com/Yojimbo/Message/index.lasso?2169

The error dialog was copied from MailToYojimbo-v1.1 by Drummond Field, posted at: http://www.hawkwings.net/2007/02/05/email-to-yojimbo-script-with- pdf-support
(Drummonds very nice script will prompt for tags.)

Steve Samuels
[EMAIL PROTECTED]
Version 11
2007/04/08
*)

--Set up a function to generate the body of the message

on generateMessageText(m)
tell application "Mail"
set _sender to sender of m
set _subject to subject of m
set _date to date received of m as string
set _contents to content of m
set _messageString to "From: " & _sender & return
set _messageString to _messageString & "Subject: " & _subject & return
set _messageString to _messageString & "Date: " & _date & return
set _messageString to _messageString & return & return & _contents
end tell

end generateMessageText

--Set a second function to pass a variable which indicates whether I sent the message or not
--
on CountSent(m)
tell application "Mail"
set _ctsent to 0 as integer
repeat with _acct in accounts
set _sender to sender of m
set _sx to extract address from _sender
if email addresses of _acct contains _sx then
set _ctsent to _ctsent + 1 as integer
-- _ctsent counts the number of times the sender's address matches one of mine
-- At the end of the function, the value of _ctsent will be 0 or 1
end if
end repeat
end tell
return _ctsent
end CountSent


--Main Program
on run
tell application "Mail"
tell message viewer 1
set messageList to selected messages
if not (exists selected messages) then
display dialog "No message was selected" & return & "Transfer cancelled." with title "Error..." giving up after 3 with icon 0 buttons {"Ok"}
return
end if
--Now loop through messages
repeat with m in messageList
set _contents to ""
set _date to ""
set _sender to ""
--Classify message as incoming or outgoing
if my CountSent(m) is 1 then
set _type to "outgoing"
end if
if my CountSent(m) is 0 then
set _type to "incoming"
end if

set _name to subject of m
set _contents to _contents & my generateMessageText(m)

--Set up date sent
set _date to date sent of m
set _yr to year of _date as string
set _month to month of _date as number

--Force month to format 'mm'
set _smon to _month as string
if _month < 10 then
set _smon to "0" & _smon
end if

--Force day to format 'dd'
set _day to day of _date as string
if day of _date < 10 then
set _day to "0" & _day
end if

-- Create date sent  with yyyy/mm/dd format
set _datef to _yr & "/" & _smon & "/" & _day

--Get sender's name & address
set _sender to sender of m
set _ssender to extract name from _sender
--If there is no name, _ssender defaults to the address
set _saddr to extract address from _sender

--If the message was received, set the name to the sender and a tag to "in"
if _type is "incoming" then
set _person to "<: " & _ssender
set _tag to "in" as string
end if

--If the message was sent, get the first recipient's name, if available, otherwise the address
if _type is "outgoing" then
set theRecipients to to recipients of m
if (exists name of item 1 of theRecipients) then
set _pers to name of item 1 of theRecipients
set _person to ">: " & _pers
else
set _addr to address of item 1 of theRecipients
set _person to ">: " & _addr
end if
set _tag to "out" as string
end if

---Now set up the note with body, comments, and tags
tell application "Yojimbo"
set aNewNoteItem to make new note item with properties {contents:_contents, name:_name, comments:_datef & " " & _person}
add tags {"email", _tag} to aNewNoteItem
end tell

end repeat
end tell
end tell
end run


--
------------------------------------------------------------------
This message is sent to you because you are subscribed to
 the mailing list <yojimbo-talk@barebones.com>.
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  <http://www.listsearch.com/yojimbotalk.lasso>
Have a feature request, or not sure if the software's workingcorrectly? Please send mail to: <[EMAIL PROTECTED]>


--
------------------------------------------------------------------
This message is sent to you because you are subscribed to
 the mailing list <yojimbo-talk@barebones.com>.
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  <http://www.listsearch.com/yojimbotalk.lasso>
Have a feature request, or not sure if the software's workingcorrectly? Please send mail to: <[EMAIL PROTECTED]>

--
Sherman



--
------------------------------------------------------------------
This message is sent to you because you are subscribed to
 the mailing list <yojimbo-talk@barebones.com>.
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  <http://www.listsearch.com/yojimbotalk.lasso>
Have a feature request, or not sure if the software's working correctly? Please send mail to: <[EMAIL PROTECTED]>

Reply via email to