AddThis Social Bookmark Button

Listen Print

Example Code for AppleScript in a Nutshell

display dialog ¬
	"Saving the jpeg now." giving up after 4

saveTheImage()

tell me to activate

display dialog "setting up and sending " & ¬
	"the email message" giving up after 4

sendTheEmail()

(* saveTheImage subroutine definition *)
on saveTheImage()
	tell application "Adobe® Photoshop® 5.5"
		activate
		do script "SaveAsJpeg"
	end tell
end saveTheImage

(* sendTheEmail subroutine definition *)
on sendTheEmail()
	set theAttachment to (¬
		choose file with prompt "Select the file attachment:")
	
	tell application "Outlook Express"
		activate
		try
			set the emailDestination to ¬
				"bwperry@mac.com"
			
			set emailSubject to ¬
				"Check out my triathlon finish!"
			
			set emailContent to "And you " & ¬
				"didn't believe that I could swim, bike, and run" & ¬
				" all in the same morning!"
			
			set emailAccount to POP account ¬
				"mac.com"
			
			set draftWindow to make new ¬
				draft window with properties ¬
				{subject:emailSubject, content:emailContent, ¬
				to recipients:emailDestination, account:emailAccount} 
					
			make attachment at draftWindow ¬
				with data {file:theAttachment, encoding:binhex}
			
			send draftWindow
		on error error_message
			
			display dialog error_message
		end try
	end tell
	
end sendTheEmail