Action
Spark Mailer
Steps
-
script
// INFORMATION // The section below defines what the expected extension template for Safari should be defined as. // This is as per discussion at https://forums.getdrafts.com/t/need-spark-action-that-sends-copies/12486/ // Line 1 = Page Title // Line 2 = URL // Line 3 = {Intentionally Blank} // Line 4+ = Selected text (if any) /* [[title]] [[url]] [[selection]] */ // Maintain the TO tag step with {name,e-mail address,nickname} // Maintain the CC tag step with {name,e-mail address} // Maintain the BCC tag step with {name,e-mail address}
-
defineTemplateTag
name TO
template Scrooge McDuck,boo@disney.com,Cheapskate Minipherd Mouse,juno@disney.com,Mini Mickalardio Mouse,sashi@disney.com,Mickey
-
defineTemplateTag
name CC
template Dubious Duck,dduck@disney.com
-
defineTemplateTag
name BCC
template -
script
// Build the "To" list of e-mail addresses and nicknames let strEmailTo = ""; let strEmailGreeting = ""; if (draft.getTemplateTag("TO") != "") { let astrToInfo = draft.getTemplateTag("TO").split("\n"); // Build e-mail address list astrTo = astrToInfo.map(strInfo => strInfo.split(",")[1].trim()); strEmailTo = astrTo.join(","); // Build nickname list astrNicknameList = astrToInfo.map(strInfo => strInfo.split(",")[2].trim()); strNicknameList = astrNicknameList.join(", ").replace(/(.*),/, "$1 and") + ":"; } // Build the "Cc" list of e-mail addresses let strEmailCc = ""; if (draft.getTemplateTag("CC") != "") { let astrCcInfo = draft.getTemplateTag("CC").split("\n"); astrCc = astrCcInfo.map(strInfo => strInfo.split(",")[1].trim()); strEmailCc = astrCc.join(","); } // Build the "Bcc" list of e-mail addresses let strEmailBcc = ""; if (draft.getTemplateTag("BCC") != "") { let astrBccInfo = draft.getTemplateTag("BCC").split("\n"); astrBcc = astrBccInfo.map(strInfo => strInfo.split(",")[1].trim()); strEmailBcc = astrBcc.join(","); } // Get the page title, URL, and selection let strPageTitle = draft.title; let strPageURL = draft.processTemplate("[[line|2]]"); let strPageSelection = draft.processTemplate("[[line|4..]]"); // Build and call the Spark URL // Use the callback object to make adding parameters easier ... but *NOT* running as a call back. // Base settings let cburlSpark = CallbackURL.create(); cburlSpark.waitForResponse = false; cburlSpark.baseURL = "readdle-spark://compose"; // Who gets it if (strEmailTo != "") cburlSpark.addParameter("recipient", strEmailTo); if (strEmailCc != "") cburlSpark.addParameter("cc", strEmailCc); if (strEmailBcc != "") cburlSpark.addParameter("bcc", strEmailBcc); // Subject line cburlSpark.addParameter("subject", strPageTitle); // Body cburlSpark.addParameter("body",`${strNicknameList} ${strPageURL} ${strPageSelection}`); // Open Spark cburlSpark.open();
Options
-
After Success Default Notification Error Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.