Ok, I officially give up... I can't figure this one out.
I have the iPhoto emailing applescript 99% changed over for use with
Emailer... but for some stupid reason it fails. It works fine if I run it
with dummy data, but as soon as I run it via iPhoto, it craps out trying
to attach the photos to an email.
I think the problem is that for some reason Emailer isn't seeing the path
to the photos as a string, despite the fact that it is. I base this off
having had the same error when I was parsing the startup disk. Originally
I collected the path to the disk, then stripped the trailing colon, then
prepended it to the path to the photos. It would fail because despite the
fact that the path was coerced into a string, AppleScript (or emailer)
wasn't seeing it that way. A slightly different placement of where I
coerced it solved that problem (originally I collected the path which
starts as an alias, then I coerced it into a string. But what I needed to
do was the coercing at the same time I collected the path, that way it
never was an alias to begin with... why the subtle difference I have NO
idea).
So based on that issue, I have a feeling it is something similar going on
with the path to the pics when provided via iPhoto. I suspect it is not
properly coercing the path into a string. I can't verify it, because
Applescript has almost NO way of debugging a script (the log function
works great... as long as you can run the script from inside the script
editor... but you can't do that when trying to run the script from inside
iPhoto!!!).
So here is what I have so far. If anyone can figure out how to get the
stupid path to work so the photos will be attached... please do. The only
other thing missing from this script is leaving the new email open for
editing (right now it creates and queues it at the same time... which is
usable, but since it lacks an address, it would just be nice if it left
it open for editing).
The script is located in the iPhoto.app package. To get to it, control
click on the iPhoto application icon, and choose Show Package Contents.
Then go into the Contents folder, and into the Resources folder, and into
the Scripts folder. The script MUST be called "Mail.scpt", and you must
quit and relauch iPhoto after editing the script (it only appears to load
it when iPhoto starts).
---Watch for line wrapping---
on �event coVScliI� theObject
try
set the image_count_return to �event appScalM� "getImageCountForEmail"
set image_count to image_count_return as integer
if image_count > 0 then
set the tmp_subject to �event appScalM� "subjectForEmail"
set email_subject to tmp_subject as string
set the tmp_address to �event appScalM� "addressForEmail"
set default_address to tmp_address as string
set the new_files to {}
set the new_captions to {}
set the new_comments to {}
repeat with image_idx from 0 to (image_count - 1)
set the file_name to �event appScalM�
"getImagePathForEmail:" given
�class witQ�:image_idx
set tmp_str to file_name as string
copy tmp_str to the end of new_files
set the file_name to �event appScalM�
"getCaptionForEmail:" given
�class witQ�:image_idx
set tmp_str to file_name as string
copy tmp_str to the end of new_captions
set the file_name to �event appScalM�
"getCommentsForEmail:" given
�class witQ�:image_idx
set tmp_str to file_name as string
copy tmp_str to the end of new_comments
end repeat
set msgBody to ""
repeat with image_idx from 1 to image_count
set this_caption to item image_idx of new_captions
set this_comment to item image_idx of new_comments
set the comments to this_caption & return &
this_comment & return &
return & return
set msgBody to msgBody & comments
end repeat
set sd to path to startup disk as string
set x to count of characters in sd
set sd to characters 1 thru (x - 1) of sd as string
set msgAttach to {}
repeat with image_idx from 1 to image_count
set this_imagefile_path to mac_path(item image_idx of
new_files as
string)
set this_imagefile_path to sd & this_imagefile_path as
string
copy this_imagefile_path to end of msgAttach
end repeat
tell application "Claris Emailer"
activate
make new outgoing message with properties
{subject:email_subject,
content:msgBody, file:msgAttach, enclosure encoding:base64}
end tell
end if
on error error_message number error_number
if the error_number is not -128 then
tell application "Finder"
activate
beep
display dialog error_message buttons {"Cancel"}
default button 1
end tell
end if
end try
end �event coVScliI�
on mac_path(unix_path)
set chars to every character of unix_path
repeat with i from 1 to length of chars
if "/" is (item i of chars as text) then
set item i of chars to ":"
end if
end repeat
return every item of chars as string
end mac_path
property ASDScriptUniqueIdentifier : "Mail.applescript"
-------END OF SCRIPT---
-chris
<http://www.mythtech.net>
___________________________________________________________________________
To unsubscribe send a mail message with a SUBJECT line of "unsubscribe" to
<[EMAIL PROTECTED]> or <[EMAIL PROTECTED]>