Hi all
I am working on a script to mail with Mac Mail
When I add for example two addresses in the script to put in the to line it will not see them as two addresses but as one so it say it is not a correct address
ron@aaaa.nl, jelle@bbbbb.nl
If I copy and paste the same string manual in the To line it is working
Any idea how to fix this ?
Hey Ron,
Google: AppleScript mail make message with multiple recipients (link1).
Brings you right to MacScripter (link2)
Stefan’s script is very similar to mine.
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone <scriptmeister@thestoneforge.com>
# dCre: 2013/05/15 06:11
# dMod: 2015/07/26 08:53
# Appl: Apple Mail
# Task: Make a new outgoing message.
# Tags: @Applescript, @Mail, @Make, @New, @Outgoing, @Message
# Test: OSX 10.10.4
-------------------------------------------------------------------------------------------
set toAddressList to {"address1@null.com", "address2@null.com", "address3@null.com"}
set _sender to "Christopher Stone <chris@null.com>"
set _subject to "Test Message"
set _body to "Now is the time for all good men to come to the aid of their country."
set _sig to "Take_Care"
tell application "Mail"
set _sig to signature _sig
set _msg to make new outgoing message with properties {subject:_subject, content:_body & return & return}
tell _msg
set visible to true
repeat with i in toAddressList
make new to recipient at end of to recipients with properties {address:i}
end repeat
set sender to _sender
set message signature to _sig
end tell
activate
end tell
------------------------------------------------------------------------------------------
You can of course add a name to the address list: {name:myName, address:myAddress}.
-Chris
MacBookPro6,1 · 2.66 GHz Intel Core i7 · 8GB RAM · OSX 10.10.4
I see, I must loop to add them all
I was hoping that it can be done in one step because copy/paste is working.
Thanks I am sure now that this is the way
Hey Rob,
I seem to remember fussing about that about 10 years ago.
The only alternative I know of is to create a group in Contacts.app and use the group-name for the name property when creating a To-Address.
It WON’T expand until sent, but I just successfully tested it on OSX 10.10.4.
-Chris
How do I use a variable in a list
you use
set toAddressList to {“address1@null.com”, “address2@null.com”, “address3@null.com”}
What if I have a string like this
“address1@null.com”, “address2@null.com”, “address3@null.com”
named mystr
Ho does the line to set the toAddressList looks like, try a few things but have no luck
Thanks
Puzzling
Are you sure that mystr is set to “address1@null.com”, “address2@null.com”, “address3@null.com” ?
If I try to compile the instruction
set mystr to “address1@null.com”, “address2@null.com”, “address3@null.com”
the editor refuse to compile. It stops highlighting the quote and the comma at the end of the first mail address.
The only way I found to make that acceptable is using:
set mystr to {“address1@null.com”, “address2@null.com”, “address3@null.com”}
Assuming that “address1@null.com”, “address2@null.com”, “address3@null.com” is written in a text file named maybe.txt on the desktop, I would use :
set p2d to path to desktop as text
set theFile to p2d & "maybe.txt"
set maybe to read file theFile
log (get class of maybe) --> (*text*)
log maybe --> (*"address1@null.com", "address2@null.com", "address3@null.com"*)
set aList to my decoupe(maybe, ", ")
log (get class of aList) --> (*list*)
log aList --> (*"address1@null.com", "address2@null.com", "address3@null.com"*)
#=====
on decoupe(t, d)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe
#=====
Yvan KOENIG running Yosemite 10.10.4 in French (VALLAURIS, France) dimanche 26 juillet 2015 21:33:22
Hi Yvan
are you sure that mystr is set to “address1@null.com”, “address2@null.com”, “address3@null.com” ?
Looks strange
I build the string in VBA code and as a parameter I bring it to a external script file out side my Excel file that the VBA code run, I can make the string as I want in my VBA code. In my examples for Excel 2011 I build the complete script in VBA and run it with the VBA MacScript function. but in Excel 2016 the MacScript function is not working correct anymore so me must use a new VBA function to call a script file.
With help from DJ I build most of the code already but only the part of more then mail address is not working yet.
Maybe I need the split script I got from DJ for this as well.
This is the thread : http://macscripter.net/viewtopic.php?id=44099
Ready with the first VBA/Script , I used the Split script from DJ also for the mail addresses now.
See this example if you want to see it : http://www.rondebruin.nl/mac/macmail/macmail2016.htm
Thanks Yvan for your time and have a nice day