Created
January 2, 2019 19:10
-
-
Save leogdion/9b39bbfede47f2df577a995537fcf80e to your computer and use it in GitHub Desktop.
Creating A Mailchimp Subscription Form and Email Invite using AppleScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set mol_list to {} | |
-- This will ask you to select a file containing the intended recepients and their emails -- | |
-- I also include in this file information needed to link to an attachment -- | |
set theFile to choose file with prompt "Select a text file:" | |
set theFileReference to open for access theFile | |
-- Note that the line end here is an old Mac return (not MSFT carriage return) -- | |
set theFileContents to read theFileReference using delimiter linefeed | |
close access theFileReference | |
-- Now parse the file that was selected. Here I'm parsing a tab-delimited file. -- | |
set text item delimiters to tab | |
-- Loop through the file one line at a time -- | |
repeat with i from 1 to count of theFileContents | |
set theLine to text items of item i of theFileContents | |
copy theLine to the end of mol_list | |
-- this identifies each column in the tab-delimited file -- | |
set full_name to item 1 of theLine | |
set first_name to item 2 of theLine | |
set last_name to item 3 of theLine | |
set middle_name to item 4 of theLine | |
set email_add to item 5 of theLine | |
-- specify the location of the file to attach -- | |
-- here I'm pasting together information from the tab-delimited file to point to the file for this particular recipient -- | |
--set file_attach to "Macintosh HD:Users:USERID:file_" & stid & ".pdf" | |
-- Set the message, again pasting together info from the recipient file -- | |
set message_content to "Dear " & first_name & ", | |
<-- Insert Content Here --> | |
https://brightdigit.com/subscribe?FNAME=" & first_name & "&LNAME=" & last_name & "&EMAIL=" & email_add & " | |
<-- Insert Content Here --> | |
Thank You, | |
Leo | |
https://twitter.com/leogdion | |
" | |
-- Now push this to Mac's mail software | |
tell application "Mail" | |
-- Create a new message with the message above and the subject -- | |
set theMessage to make new outgoing message with properties {visible:true, subject:"Find Out What's New With BrightDigit", content:message_content, sender:"[email protected]"} | |
-- Set the address for this recipient -- | |
tell theMessage | |
make new to recipient at end of to recipients with properties {address:email_add} | |
end tell | |
save theMessage | |
end tell | |
end repeat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var urlParams = new URLSearchParams(window.location.search); | |
document.getElementById('mce-FNAME').value = urlParams.get('FNAME') | |
document.getElementById('mce-LNAME').value = urlParams.get('LNAME') | |
document.getElementById('mce-EMAIL').value = urlParams.get('EMAIL') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment