Sto provando a sostituire un indirizzo email per un personaggio simbolico in un blocco di testo.
Il blocco di testo:
Dear %%FirstName%%-
...
This message was sent to %%EmailAddress%%.
Lo script:
...
set theBody to my replace(theBody, "%%FirstName%%", "First")
set theBody to my replace(theBody, "%%EmailAddress%%", "[email protected]")
...
Sostituisci procedura secondaria ( AppleScript: routine secondarie essenziali ):
on replace(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace
Il risultato:
Dear First-
...
This message was sent to .
Se cambio lo script in:
...
set theBody to my replace(theBody, "%%FirstName%%", "First")
set theBody to my replace(theBody, "%%EmailAddress%%", "first.lastATcompany.com")
Il risultato:
Dear First-
...
This message was sent to first.lastATcompany.com.
Cosa c'è di sbagliato nella sottoprocedura replace
?
** modifica **
Sto raccogliendo un elenco distinto di indirizzi email da un contatto di Outlook:
...
set theAddresses to email addresses of theContact
set addressList to {}
repeat with theAddress in the theAddresses
if addressList does not contain (address of theAddress) then
set addressList to addressList & (address of theAddress)
end if
end repeat
...
Quindi usa l'elenco:
...
repeat with theAddress in addressList
...
make new recipient at newMessage with properties {email address:{name:displayName of theContact, address:theAddress}}
...
end repeat
...