this script was found in iPhoto 1.1 (Contents -> Resources -> Scripts -> Mail.scpt) which enables one to attach selected photos to a new message in Apple's Mail app. Can some proficient in AppleScript customize it for Entourage? I would love to but this seems a bit too complex for me :(
TIA!
rds,
qoo
-- Mail.applescript
-- Scope
-- Created by Glenn Reid on Thu Jan 17 2002.
-- Copyright (c) 2001 Apple Computer. All rights reserved.
property type_list : {"JPEG", "GIFf", "PICT", "TIFF"}
property extension_list : {"jpg", "gif", "pct", "tif"}
--property default_recipient : "John Doe"
property scale_images : true
property target_dimension : 480
property pick_destination : false
property test_file : "/Library/Desktop Pictures/Nature/Ladybug.jpg"
global new_message
on «event coVScliI» theObject
--display dialog "Mail iPhoto Images"
try
-- ADD THE IMAGES TO A NEW MAIL MESSAGE
--set mail_file to call method "firstSelectedImagePath" of object document 1 of window "main"
--set the mail_file to call method "firstSelectedImagePath" of object view "archivedocument" of window "main"
--set the mail_file to the name of the document of window "iPhoto"
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
--get the subject and address from the app
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 {}
--set new_files_ref to a reference to new_files
--set numItems to image_count
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
--set mail_file to item image_idx+1 of the new_files
--set the end of the new_files to mail_file
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
tell application "Mail"
activate
set the new_message to ¬
make new compose message at beginning of every compose message
tell new_message
--make new recipient at beginning of to recipients with properties {address:default_address, display name:default_recipient}
set the subject to email_subject
set the content to return & return & return & return
--tell content
--repeat with this_imagefile in the new_files
repeat with image_idx from 1 to image_count
set this_caption to Abstract object image_idx of new_captions
set this_comment to Abstract object image_idx of new_comments
set the comments to this_caption & return & this_comment & return & return & return
set the content to content & comments
end repeat
repeat with image_idx from 1 to image_count
set this_imagefile to Abstract object image_idx of new_files
set this_caption to Abstract object image_idx of new_captions
set this_comment to Abstract object image_idx of new_comments
--set this_imagefile to the contents of this_imagefile
set the comments to this_caption & return & this_comment
--make new text attachment with properties {file name:this_imagefile} at before the first word of the first paragraph
tell content
--make new text attachment with properties {file name:this_imagefile} at before the first word of the first paragraph
repeat with image_idx from 1 to image_count
set this_imagefile to Abstract object image_idx end tell
--set paragraph 1 of content to paragraph 1 of content & comments
--copy the comments to the end of paragraph 1 of content
end repeat
--set this_imagefile to the contents of mail_file
--make new text attachment with properties {file name:this_imagefile} at before the first word of the first paragraph
--end tell
end tell
make new message editor at beginning of every message editor
--if (version is equal to 1.0 or version is equal to 1.1) then
set compose message of last message editor to new_message
--else
-- set compose message of first message editor to new_message
--end if
enp; end tell
--set paragraph 1 of content to paragraph 1 of content & comments
--copy the comments to the end of paragraph 1 of OLOR="#FF0000">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 run
repeat
display dialog "Mail iPhoto Images" & return & return & ¬
"Drag images from the iPhoto window onto this droplet to attach the images to a new outgoing message in the Mail application." buttons {"Set Prefs", "Done"} default button 2
if the button returned of the result is "Done" then exit repeat
-- PREFERENCES
display dialog "Should the images be re-sized before adding them to an email?" buttons {"Skip", "No", "Yes"} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "YOLOR="#FF0000">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 run
repeat
display dialog "Mail iPhoto Images" & return & return & ¬
en
set pick_destination to true
else if the button returned of the result is "No" then
set pick_destination to false
end if
repeat
try
display dialog "Enter the size (in pixels) for the image files:" default answer (target_dimension as string) buttons {"Skip", "Set"} default button 2
copy the result as list to {this_text, button_pressed}
if the button_pressed is "Set" then
set this_amount to this_text as integer
if this_amount is greater than 12 then
set the target_dimension to this_amount
exit repeat
end if
else
exit repeat
end if
end try
end repeat
else if the button_pressed is "No" then
set scale_images to false
end if
display dialog "Enter the text for the email subject line:" default answer email_subject buttons {"Skip", "None", "Set"} default button 3
copy the result as list to {this_text, button_pressed}
if the button_pressed is "Set" then
set email_subject to this_text
else if the button_pressed is "None" then
set email_subject to ""
end if
display dialog "Enter the name of the default recipient:" default answer default_recipient buttons {"Skip", "None", "Set"} default button 3
copy the result as list to {this_text, button_pressed}
if the button_pressed is "Set" then
set default_recipient to this_text
else if the button_pressed is "None" then
set default_recipient to ""
end if
display dialog "Enter the email address of the default recipient:" default answer default_address buttons {"Skip", "None", "Set"} default button 3
copy the result as list to {this_text, button_pressed}
if the button_pressed is "Set" then
set default_address to this_text
else if the button_pressed is "None" then
set default_address to ""
end if
end repeat
end run
on open these_items
set these_imagefiles to {}
-- EXAMINE AND PROCESS EACH DRAGGED-ON ITEM
repeat with i from 1 to the count of these_items
set this_item to (item i of these_items)
-- GET THE INFO FOR THIS ITEM
set the item_info to info for this_item
if ((folder of the item_info is false) and ¬
(alias of the item_info is false)) and ¬
(the file type of the item_info is in the type_list) or ¬
((the name extension of the item_info) is in the extension_list) then
-- IF THE ITEM IS NOT A FOLDER OR AN ALIAS AND ITS FILE TYPE IS IN THE LIST,
-- OR IT'S FILENAME ENDS WITH THE CORRECT EXTENSION, THEN PROCESS THE ITEM
set the end of these_imagefiles to this_item
end if
end repeat
if these_imagefiles is not {} then
process_list(these_imagefiles)
end if
end open
on process_list(these_imagefiles)
try
if pick_destination is true then
activate
set the target_folder to choose folder with prompt "Pick a destination for the image files:"
else
set the temp_folder to (path to temporary items folder)
repeat
set this_name to (random number from 10000 to 99999) as string
tell application "Finder"
if not (exists item this_name of temp_folder) then
set the target_folder to (make new folder at temp_folder with properties {name:this_name})
exit repeat
end if
end tell
end repeat
end if
if scale_images is true then
tell application "Finder"
-- MAKE DUPLICATES OF THE IMAGES IN THE TARGET FOLDER
set the new_files to {}
repeat with i from 1 to the count of these_imagefiles
set this_imagefile to item i of these_imagefiles
set this_name to the name of this_imagefile
if (exists file this_name of the target_folder) then
delete file this_name of the target_folder
end if
set this_filepath to duplicate this_imagefile to the target_folder with replacing
set this_name to (random number from 10000 to 99999) as string
tell application "Finder"
if not (exists item this_name of temp_folder) then
set the target_folder to (make new folder at n
-- SCALE THE IMAGES TO THE DEFAULT SIZE
repeat with i from 1 to the count of the new_files
set this_imagefile to item i of the new_files
tell application "Image Capture Scripting"
set this_image to open this_imagefile
scale this_image to size target_dimension
save this_image in this_imagefile
close this_image
end tell
end repeat
end if
-- ADD THE IMAGES TO A NEW MAIL MESSAGE
tell application "Mail"
activate
set the new_message to ¬
make new compose message at beginning of every compose message
tell new_message
make new recipient at beginning of to recipients with properties {address:default_address, display name:default_recipient}
set the subject to email_subject
set the content to return --"Here are some images for you." & return
tell content
repeat with this_imagefile in the new_files
set this_imagefile to the contents of this_imagefile
make new text attachment with properties {file name:this_imagefile} at before the first word of the first paragraph
end repeat
end tell
end tell
make new message editor at beginning of every message editor
set compose message of first message editor to new_message
end tell
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 process_list
property ASDScriptUniqueIdentifier : "Mail.applescript"
