Re: Pipe Email to Yojimbo

2007-04-16 Thread Steven Samuels
This is a test.  The Yojimbo-Talk web page is breaking up long lines  
with hard returns, so that users who copy the script from there  
experience errors. To try to prevent the problem, I have tried  
breaking up long lines with Applescript continuation characters.


Steve

(*
Script to pipe selected Apple Mail messages to Yojimbo notes

Author: Steve Samuels ([EMAIL PROTECTED])
File: yojimbo22.txt
PipeMailtoYojimbo.scpt

Version:22
Date: 2007/04/16

This script is based on one by Jim Correia of Barebones, cited  
below.  It adds the following information to to the Comments  of an  
imported email note.  If the comments Column is visible in Yojimbo's  
Item List Pane, then the information can be viewed without opening  
the note.



* Added to Comments
  1) the date sent (/mm/dd)
  2) the name or address of sender or recipient
  3) the first 60 characters of the message itself it, after  
removing returns, tabs, and most extra spaces.


* Adds tags: email  either in or out

After running the script, a Comment will look something like:

2007/04/08 : NYTimes.com---Your subscription is up soon. Please  
rene   (an incoming message)

or
2007/04/09 : Sam---Hi, Sam! I can't believe that you won the  
lotte (an outgoing message)


Notes:

IMPORTANT: Before inserting the script into script-editor, open it in  
a text editor like BBEdit or Text Wrangler.  Scroll down to a section


1. Text will not import for some rich text messages with  
attachments.  The date sent, sender  tags are added, but  
AppleScript's content of message function returns only variants of  
??. If this happens, open the original message  cut  paste the  
content into the note created by the script.


2. Graphics are removed and replaced by question marks. If you  wish  
to retain the graphics, import the mail via the Save PDF to Yojimbo  
option in Mail's Print window.


3. A message is classified as outgoing if the sender's address  
matches one of the user's addresses. If an account has been deleted,  
there is no address to match, and all messages in the account will be  
classified as incoming. To fix this behavior, create and inactivate a  
dummy account. Only the email address must be correct; the other  
settings are irrelevant.


4. You can reset the number of characters that are added to comments  
from the body of the message. The setting statement appears just  
after the on run command at the start of the script proper.


5. If you have selected messages in more than one Message Viewer, the  
script transfers only those from the Viewer that was opened first.


6. Changing the font of Yojimbo's item list may make the the list  
more readable. (I now use Lucinda-Grande Bold 11)



Acknowledgements:

The original form for this script was based on MailtoYojimbo, by Jim  
Correia of Bare Bones Software, posted in the Yojimbo Talk Forum:  
http://www.listsearch.com/Yojimbo/Message/index.lasso?2169

 at //www.hawkwings.net/2006/09/04/script-to-pipe-emails-into-yojimbo/

I got the idea for adding extended message information to the  
comments field after seeing the Summary field in SOHO Notes.


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


The source for the minimum function was:
http://www.macresearch.org/no_need_to_parse_an_expression

The form for the shell script was based on examples at:
http://developer.apple.com/technotes/tn2002/tn2065.html
http://developer.apple.com/documentation/OpenSource/Conceptual/ 
ShellScripting/RegularExpressionsUnfettered/chapter_6_section_9.html

*)

on run
---
--In the set _maxcontent statement below, specify how many characters
--from the message to add to comments. Zero is a possible value.
---
set _maxcontent to 60 as integer
tell application Yojimbo
activate
end tell
tell application Mail
activate
if not (exists message viewer 1) then
display dialog ¬
No Viewer Window is Open. Open one  select messages.¬
 return with title Error¬
giving up after 3 with icon 0
return
end if
tell message viewer 1
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
return
end if
set messageList to selected messages
--Now loop through messages
repeat with m in messageList
--Initialize
set _type to 
set _contents to 
set _name to 
set _person to 
set _tag to 
set _body to 
--Classify message as incoming or outgoing
set _count to my CountSent(m) as integer
if _count is 1 then
set _type to outgoing
else
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 

Re: Pipe Email to Yojimbo

2007-04-16 Thread Steven Samuels

Version 22

1. The Yojimbo-Talk web page i breaks up long lines with hard  
returns. This caused errors for users who copied previous versions of  
the script from there. To fix this problem, I broke up long lines  
with Applescript continuation characters ¬.  The error did not  
affect anyone who copied the script from their email.


2. The post of Version of 21 had two copies of the script and should  
therefore be replaced.


Steve

(*
Script to pipe selected Apple Mail messages to Yojimbo notes

Author: Steve Samuels ([EMAIL PROTECTED])
File: yojimbo22.txt
PipeMailtoYojimbo.scpt

Version:22
Reformatted to shorter lines
Date: 2007/04/16

This script is based on one by Jim Correia of Barebones, cited  
below.  It adds the following information to to the Comments  of an  
imported email note.  If the comments Column is visible in Yojimbo's  
Item List Pane, then the information can be viewed without opening  
the note.



* Added to Comments
  1) the date sent (/mm/dd)
  2) the name or address of sender or recipient
  3) the first 60 characters of the message itself it, after  
removing returns, tabs, and most extra spaces.


* Adds tags: email  either in or out

After running the script, a Comment will look something like:

2007/04/08 : NYTimes.com---Your subscription is up soon. Please  
rene   (an incoming message)

or
2007/04/09 : Sam---Hi, Sam! I can't believe that you won the  
lotte (an outgoing message)


Notes:

IMPORTANT: Before inserting the script into script-editor, open it in  
a text editor like BBEdit or Text Wrangler.  Scroll down to a section


1. Text will not import for some rich text messages with  
attachments.  The date sent, sender  tags are added, but  
AppleScript's content of message function returns only variants of  
??. If this happens, open the original message  cut  paste the  
content into the note created by the script.


2. Graphics are removed and replaced by question marks. If you  wish  
to retain the graphics, import the mail via the Save PDF to Yojimbo  
option in Mail's Print window.


3. A message is classified as outgoing if the sender's address  
matches one of the user's addresses. If an account has been deleted,  
there is no address to match, and all messages in the account will be  
classified as incoming. To fix this behavior, create and inactivate a  
dummy account. Only the email address must be correct; the other  
settings are irrelevant.


4. You can reset the number of characters that are added to comments  
from the body of the message. The setting statement appears just  
after the on run command at the start of the script proper.


5. If you have selected messages in more than one Message Viewer, the  
script transfers only those from the Viewer that was opened first.


6. Changing the font of Yojimbo's item list may make the the list  
more readable. (I now use Lucinda-Grande Bold 11)



Acknowledgements:

The original form for this script was based on MailtoYojimbo, by Jim  
Correia of Bare Bones Software, posted in the Yojimbo Talk Forum:  
http://www.listsearch.com/Yojimbo/Message/index.lasso?2169

 at //www.hawkwings.net/2006/09/04/script-to-pipe-emails-into-yojimbo/

I got the idea for adding extended message information to the  
comments field after seeing the Summary field in SOHO Notes.


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


The source for the minimum function was:
http://www.macresearch.org/no_need_to_parse_an_expression

The form for the shell script was based on examples at:
http://developer.apple.com/technotes/tn2002/tn2065.html
http://developer.apple.com/documentation/OpenSource/Conceptual/ 
ShellScripting/RegularExpressionsUnfettered/chapter_6_section_9.html

*)

on run
---
--In the set _maxcontent statement below, specify how many characters
--from the message to add to comments. Zero is a possible value.
---
set _maxcontent to 60 as integer
tell application Yojimbo
activate
end tell
tell application Mail
activate
if not (exists message viewer 1) then
display dialog ¬
No Viewer Window is Open. Open one  select messages.¬
 return with title Error¬
giving up after 3 with icon 0
return
end if
tell message viewer 1
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
return
end if
set messageList to selected messages
--Now loop through messages
repeat with m in messageList
--Initialize
set _type to 
set _contents to 
set _name to 
set _person to 
set _tag to 
set _body to 
--Classify message as incoming or outgoing
set _count to my CountSent(m) as integer
if _count is 1 then
set _type to outgoing
else
set _type to incoming
end if
set _name to subject of m
set 

Pipe Mail to Yojimbo V 17

2007-04-13 Thread Steven Samuels

There are two main reasons for this revision:

* To alert users that text will not import for some rich text  
messages with attachments. In these cases, AppleScript's content of  
message operator returns only variants of ??. The suggested work- 
around is to forward the message to yourself after deleting the  
attachments.


* Version 16 gave an uninformative Applescript Error Message if no  
messages were selected.  This has been fixed.


Other changes:
* The name-content separator in Comments is changed form ___ to  
---.  This, to my eye at least, makes the Comments line more readable.

* Some typos are corrected and the code is tweaked.
* The notes are revised. Please read them.


Script Follows below next line:
 
__

(*
enhanced script to pipe selected Apple Mail messages to Yojimbo notes

Author: Steve Samuels ([EMAIL PROTECTED])
File: yojimbo17.txt
PipeMailtoYojimbo.scpt

Version : 17
Date: 2007/04/13

Besides importing messages, the script:

* Adds to message Comments:
1) the date sent (/mm/dd)
2) the name or address of sender or recipient
3) the first 60 characters of the message itself it, after removing  
returns, tabs, and most extra spaces.

(The number of characters can be reset in Script Editor.)
* Adds tags: email  either in or out
After running the script, a Comment will look something like:

2007/04/08 : NYTimes.com _Your subscription is up soon. Please  
rene   (an incoming message)

or
2007/04/09 : Sam _I can't believe that you won the  
lottery(an outgoing message)



*
MAJOR ISSUE: THE MESSAGES OF CERTAIN RICH TEXT DOCUMENTS WITH  
ATTACHMENTS WILL NOT IMPORT. THE MESSAGE CONTENT WILL SHOW AS ???  
OR SOMETHING LIKE IT. IF THIS OCCURS, FORWARD THE MESSAGE TO YOURSELF  
WITHOUT ATTACHMENTS.

*
Notes:

1. Graphics are removed and shown as question marks, e.g. ??

2. A message is classified as outgoing if the sender's address  
matches one of the user's addresses. If an account has been deleted,  
there is no address to match, and all messages in the account will be  
classified as incoming. To fix this behavior, create and inactivate a  
dummy account. Only the email address must be correct; the other  
settings are irrelevant.


3. You can reset the number of characters that are added to comments  
from the body of the message. The setting statement appears just  
after the on run command at the start of the script proper. Zero is  
a possible entry.


4. If you have selected messages in more than one Message Viewer, the  
script transfers only those from the Viewer that was opened first.


5. Changing the font of Yojimbo's item list may make the the list  
more readable. (I now use Lucinda-Grande Bold 11)


.
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

 at //www.hawkwings.net/2006/09/04/script-to-pipe-emails-into-yojimbo/

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


The source for the minimum function was:
http://www.macresearch.org/no_need_to_parse_an_expression

The form for the shell script was based on examples at:
http://developer.apple.com/technotes/tn2002/tn2065.html
http://developer.apple.com/documentation/OpenSource/Conceptual/ 
ShellScripting/RegularExpressionsUnfettered/chapter_6_section_9.html



*)

on run
--SPECIFY HOW HOW MUCH OF THE MESSAGE TO ADD TO COMMENTS. IF NONE,  
SET THE NUMBER TO ZERO

set _maxcontent to 60 as integer
tell application Yojimbo
activate
end tell
tell application Mail
activate
if not (exists message viewer 1) then
display dialog No Viewer Window is Open. Open one  select  
messages.  return with title Error giving up after 3 with icon 0

return
end if
tell message viewer 1
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

return
end if
set messageList to selected messages
--Now loop through messages
repeat with m in messageList
--Initialize
set _type to 
set _contents to 
set _name to 
set _person to 
set _tag to 
set _body to 
--Classify message as incoming or outgoing
set _count to my CountSent(m) as integer
if _count is 1 then
set _type to outgoing
else
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