Script no longer sends mail since upgrade to 10.5

I also consructed a massage according to how Ben discribes it in the article

tell application "Mail"
	set theMessage to make new outgoing message with properties {visible:true, subject:"My Subject", content:"My Body"}
	tell theMessage
		make new to recipient at end of to recipients with properties {name:"Ben Waldie", address:"123@xyz.com", sender:"me@me.com"}
	end tell
	send theMessage
end tell

same problem if Mail is quit it does not send it and it does not change the sender.

AppleScriptGuru is just a sample name of a mail account. You have to rename it in literal strings with one of your own account names.

Try this script, it creates sender and recipient automatically from your own accounts by choosing one from a list
then sends a message from a certain account to another (different) one


tell application "Mail"
	set listOfSenders to {}
	set everyAccount to every account
	repeat with eachAccount in everyAccount
		set everyEmailAddress to email addresses of eachAccount
		if (everyEmailAddress is not equal to missing value) then
			repeat with eachEmailAddress in everyEmailAddress
				set listOfSenders to listOfSenders & {(full name of eachAccount & " <" & eachEmailAddress & ">") as string}
			end repeat
		end if
	end repeat
	set theResult to choose from list listOfSenders with prompt "Which account would you like to send this message from?"
	if theResult is false then return
	set theSender to item 1 of theResult
	
	set listOfRecipients to {}
	repeat with oneSender in listOfSenders
		if theSender is not contents of oneSender then set end of listOfRecipients to contents of oneSender
	end repeat
	set theResult to choose from list listOfRecipients with prompt "Which address would you like to send this message to?"
	if theResult is false then return
	set theRecipient to item 1 of theResult
	
	set o to offset of "<" in theRecipient
	set theName to text 1 thru (o - 2) of theRecipient
	set theAddress to text (o + 1) thru -2 of theRecipient
	
	set theMessage to make new outgoing message with properties {visible:true, subject:"My Subject", content:"My Body"}
	tell theMessage
		set sender to theSender
		make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
	end tell
	send theMessage
end tell

Ok Stefan got it, and the script runs BTW. still no further on my problem.

In the mean time I have been trying to get it to work under Entourage.

But I do not know how to script setting a sender. do you?

I have:

set theSubject to "Subject"
set theBody to "Body"
tell application "Microsoft Entourage"
	set theRecipients to {{address:{display name:"XXX", address:"xx@xyz.com"}, recipient type:to recipient}}
	set theMessage to make new outgoing message with properties {recipient:theRecipients, subject:theSubject, content:theBody}
	open theMessage
end tell

thanks

Unfortunately no, I don’t use Entourage

The AppleScript dictionary of Entourage mentions a «sender» property. So maybe this might work:


set theSubject to "Subject"
set theBody to "Body"
tell application "Microsoft Entourage"
	set theRecipients to {{address:{display name:"XXX", address:"xx@xyz.com"}, recipient type:to recipient}}
	set theMessage to make new outgoing message with properties {recipient:theRecipients, subject:theSubject, content:theBody}
	open theMessage
	set sender of theMessage to "miracoli@spaghetti.bol"
end tell

had tried that but does not work.

set theSubject to "Subject"
set theBody to "Body"
tell application "Microsoft Entourage"
   set theRecipients to {{address:{display name:"XXX", address:"xx@xyz.com"}, recipient type:to recipient}}
   set theMessage to make new outgoing message with properties {recipient:theRecipients, subject:theSubject, content:theBody}
   open theMessage
   set sender of theMessage to "miracoli@spaghetti.bol"
end tell

That does not work it just takes the default account.

I also tried:

tell application "Microsoft Entourage"
   set theMessage to make new outgoing message with properties {recipient:"xx@xyz.com", subject:"Subject", content:"Body"}
   tell theMessage
       set sender to {address:"miracoli@spaghetti.bol", display name:"miracoli spaghetti"}
       send
   end tell
end tell

and that works, but it now does only take “miracoli spaghetti” but not “miracoli@spaghetti.bol”, here it still takes the default account, not sure how to fix this. do you?

Martin Thanks,

It works but does not change the sender, it uses the one form my main account. any ideas as to why? I am lost.