Mail.app - 2 or more recipients - Won't Send

Hello All,

I cannot send email to multiple recipients from FileMaker 13 using Apple Mail 7.3 (Mac OS X 10.9.4). This method has worked since 2008, but has broken since the upgrade to Mavericks. I have tested the script under FM 13 and Apple Mail 6.6, and it still works. I am using AppleScript to send the email, but I get the same results if I send using FMP’s Send Email script step.

From the FileMaker script, addresses are appended with a comma-space between addresses (e.g., billthecat@domain.com, fred@domain.com).

Mail.app treats the text from the field as one large address, regardless of the comma. If only one address is in the field, the email goes out without a problem. The specific error is:

billthecat@domain.com, fred@domain.com” does not appear to be a valid email address. Verify the address and try again.

This error occurs whether I use AppleScript or Send Email methods.

I have tried using a semi-colon as delimiter. I have also tried adding quotes around each address in the FileMaker field, to provide a “list” to AppleScript.

In Mail.app, if I delete the space between the addresses and add it back, the addresses are recognized as separate addresses!

How can I get Mail.app to recognize the text string for what it is?

Here is the script, run from inside FileMaker Pro:


tell application "FileMaker Pro Advanced"
	set theAttachment to cell "gText" of the table "History"
	set theReceiver to cell "eMail" of the current record of the database "History" as list
	set theSubject to cell "Topic" of the current record of the database "History"
	set theBody to cell "Text" of the current record of the database "History" & return & return
	tell me
		if theAttachment is equal to "" then
			set theAttachment to "NONE"
		else if theAttachment is not equal to "NONE" then
			set theAttachment to POSIX path of theAttachment
		end if
	end tell
end tell -- FileMaker
tell application "Mail"
	set newMessage to (make new outgoing message with properties {subject:theSubject, visible:true})
	set sig to newMessage's message signature
	set content of newMessage to theBody
	set message signature of newMessage to sig
	tell newMessage
		repeat with i from 1 to count theReceiver
			make new to recipient at end of to recipients with properties {address:item i of theReceiver}
		end repeat
		if theAttachment is not equal to "NONE" then
			tell content of newMessage
				make new attachment with properties {file name:theAttachment} at after the last paragraph
			end tell -- content
		end if
	end tell -- newMessage
	activate
end tell --Mail.app

What am I doing wrong?

John

Hi,

you have to use text item delimiters to create an AppleScript list from the literal text list.


tell application "FileMaker Pro Advanced"
	set theAttachment to cell "gText" of the table "History"
	set theReceiver to cell "eMail" of the current record of the database "History" -- no list coercion !
	set theSubject to cell "Topic" of the current record of the database "History"
	set theBody to cell "Text" of the current record of the database "History" & return & return
	tell me
		if theAttachment is equal to "" then
			set theAttachment to "NONE"
		else if theAttachment is not equal to "NONE" then
			set theAttachment to POSIX path of theAttachment
		end if
	end tell
end tell -- FileMaker
set {TID, text item delimiters} to {text item delimiters, ", "}
set theReceiver to theReceiver as text
set text item delimiters to TID
tell application "Mail"
	-- .


Hello Stefan,

Thank you for your response!

I edited the top part of the script so that it looks like this:


tell application "FileMaker Pro Advanced"
	set theAttachment to cell "gText" of the table "History"
	set theReceiver to cell "eMail" of the current record of the database "History"
	set theSubject to cell "Topic" of the current record of the database "History"
	set theBody to cell "Text" of the current record of the database "History" & return & return
	tell me
		set {TID, text item delimiters} to {text item delimiters, ", "}
		set theReceiver to theReceiver as text
		set text item delimiters to TID
		if theAttachment is equal to "" then
			set theAttachment to "NONE"
		else if theAttachment is not equal to "NONE" then
			set theAttachment to POSIX path of theAttachment
		end if
	end tell
end tell -- FileMaker

The end result is that it treats each character as a separate list item. It looks like this in the to: field of Mail.app
f
r
e
d
@
d
o
m
a
i
n
.
c
o
m

It is as if the text from the field is being treated as some other data type.

sorry, it’s the opposite way


tell application "FileMaker Pro Advanced"
	set theAttachment to cell "gText" of the table "History"
	set theReceiver to cell "eMail" of the current record of the database "History"
	set theSubject to cell "Topic" of the current record of the database "History"
	set theBody to cell "Text" of the current record of the database "History" & return & return
end tell -- FileMaker
set {TID, text item delimiters} to {text item delimiters, ", "}
set theReceiver to text items of theReceiver
set text item delimiters to TID
if theAttachment is equal to "" then
	set theAttachment to "NONE"
else if theAttachment is not equal to "NONE" then
	set theAttachment to POSIX path of theAttachment
end if

the tell me block is actually not needed

Stefan,

Thank you! The coercion into list format did the trick.

Regarding the tell me statements, they are needed, as I am calling this script from within a FileMaker script. Otherwise, FileMaker tries to perform these lines. I end up with an Object Not Found error on Text Item Delimiters.

Thank you again. I have been knocking my head on this problem for several days now.

John