Uploading image to Flickr via AppleScript

Uploading image to Flickr via AppleScript

set email_address to "[email protected]"

tell application "iPhoto"
	activate
	set theSelection to the selection
	if (count of theSelection) = 0 then
		display dialog "You should select a photograph."
		return
	end if
	if (count of theSelection) > 1 then
		display dialog "You cannnot select more than one photograph."
		return
	end if
	set thePhoto to item 1 of theSelection
	set imagePath to image path of thePhoto as string
	set TitleStr to (display dialog "Title:" default answer "" buttons {"OK", "Cansel"} default button 1)
	if (button returned of TitleStr) = "OK" then
		set theSubject to (text returned of TitleStr)
	else
		return
	end if
	set Discription to (display dialog "Discription:" default answer "" buttons {"OK", "Cansel"} default button 1)
	if (button returned of Discription) = "OK" then
		set DiscriptionStr to (text returned of Discription)
	else
		return
	end if
	set Tags to (display dialog "tags:" default answer "" buttons {"OK", "Cansel"} default button 1)
	if (button returned of Tags) = "OK" then
		set TagsStr to (text returned of Tags)
	else
		return
	end if
	if TagsStr = "" then
		set theMessage to DiscriptionStr & return
	else
		set theMessage to DiscriptionStr & return & "tags:" & TagsStr & return
	end if
end tell

tell application "Mail"
	activate
	set composeMessage to (a reference to (make new outgoing message))
	tell composeMessage
		make new to recipient with properties {address:email_address}
		set the subject to theSubject
		set the content to theMessage
		tell content
			make new attachment with properties {file name:imagePath} at after the last word of the last paragraph
		end tell
	end tell
	save composeMessage
	display dialog "Your mail to flickr.com has been saved." & return & "Are you sure to send the mail?" buttons {"OK", "Cansel"} default button 1
	set SendCheck to button returned of result
	if SendCheck = "OK" then
		send composeMessage
	else
		display dialog "You shoud delete or edit the mail in Drafts mailbox" buttons {"OK"} default button 1
		return
	end if
end tell

你可能感兴趣的:(properties,image,application,dialog,button,tags)