Need Spark Action that Sends Copies

Please excuse me if I’m posting this in the wrong area of the Community.

I much prefer Spark over Mail.

Mail is very well supported by Drafts via the Mail Action Step, but I’m having trouble finding a similar level of support for Spark. Yes, there are four Actions for Spark in the directory, but none of them enables all the parameters of Spark’s x-callback-url scheme: subject, body, to, cc, and bcc. Specially, I need support for all these parameters other than bcc.

How do I write my own Action Step for Spark that supports at least: subject, body, to, and cc?

Thank you for your help.

UPDATE April 17, 2022 12:18 PM

@FlohGro
Thank you for telling me the correct area of the Community for this post. Hopefully I’ve moved it correctly.

@sylumer and @FlohGro
Apparently, Spark does NOT have x-callback-url support. I apologize for using the term incorrectly.

Is it definitely a full x-callback-url scheme?

Maybe move the topic to „Actions & Help Questions“ :wink:

I just looked at the page you linked in another post with all the url schemes (Complete List of iOS URL Schemes for Third-Party Apps (Always-Updated) | by Justin Meyers | Medium)
There are some examples on how you can create your own link with the parameters you want to use.

To better help you: can you share a few more details what you want to do exactly?
Do you want to type those parameters like subject / recipients / cc/…) into a Prompt or shall the action e.g. use the first line of the draft as subject?
Are the recipients always the same persons / just a few persons where you want to select from or are they changing very often?

1 Like

I don’t think so, too.
So the resulting action will then „end“ in Spark but should definitely be possible With the available parameters to open the compose window of Spark with all the info prefilled

Thank you for your reply.

I find that I am often reading a web page in iOS Safari and want to share it with someone else, almost always one of just a few sets of people.

My current workflow, starting with the page I want to share loaded in iOS Safari:

  1. Within iOS Safari, tap the Share icon and choose Spark. This opens a new Spark message with the page’s HTML TITLE in the SUBJECT and the URL in the BODY.

  2. Within Spark, address the message with one of a recurring list of TO and (and sometimes CC) recipients, add a salutation at the top of the BODY (ahead of the URL) that corresponds to the names of the TO recipient(s), and (after the salutation) type some unique text explaining why I’m referring the recipients to the page. Then swipe through my stored signatures and choose the one corresponding to my TO recipient(s). Finally, to defer sending the message, tap on X at the top of the screen and choose Save Draft. This closes the message and puts it in the Drafts folder of my Gmail account.

  3. Launch the Gmail app, navigate to the Drafts folder, select this message, and schedule its delivery for a unique day, usually at the same time.

Done!

By the way, yes I know that Spark can do client-side deferred delivery. But I prefer server-side deferred delivery (via Gmail) so I can later access the staged messages from any of my devices in order to: see the subject and delivery times for all scheduled messages, edit a message, or reschedule a delivery.

The workflow that I’m trying to achieve is, starting with the page loaded in iOS Safari:

  1. Within iOS Safari, tap Share and choose Drafts. This will create a new draft with only the TITLE and URL (without a delimiter between them, unfortunately).

  2. Within Drafts, tap an Action that gives me a menu of recipients. Upon making a selection from this menu, Drafts opens a new message in Spark with the following prefilled: TO, CC (if any), SUBJECT (with HTML Title), and BODY (with Salutation based on menu selection, and URL). Drafts should leave me in Spark in order for me to: manually edit SUBJECT (if necessary), write custom text in BODY, and select Signature (unless it can somehow be preselected based on the menu choice).

The remainder of the workflow remains unchanged, continuing to: within Spark, cancel the message and save a draft; launch Gmail, navigate to Drafts folder, and schedule deferred delivery.

What do you think?

thanks for the clarification.

Maybe this action is what you’re searching for: spark mail composer | Drafts Directory

If not, you can change the script to your needs or just ask if something needs smaller adaptions and you cant figure it out.
Before using it the first time - you have to configure the optional recipients (cc’s/bcc’s) in the script step.

Additionally regarding (1.) you can change the template from a web share in the settings > Share & Action to your needs.

1 Like

Wow! Thank you. I’m brand new to Drafts and had no idea how to create a new action.

I’ll look at this later; right now I need to prepare for our Easter family gathering, our first post Covid-19.

Happy Easter :hatching_chick: (If you celebrate it).

Thanks again.

Welcome to the community :v:t4:

Happy Easter to you :blush: celebrating it too​:+1:t3:

Let me know if the action works for you or if anything is not clear. It’s not that well documented right now but hopefully enough :wink:

I presume that changes made here are going to apply every time that something is Shared to Drafts. So if I change this template in settings, isn’t likely to break some other action because that action isn’t getting what it expected?

I’m thinking of changing the template to:

[[title]]
[[url]]

[[selection]]

Note that I’ve removed the Markdown characters “” and “()” from the TITLE and URL, respectively, so it will not render as a link.

Likewise, I’ve removed the “>” so Markdown won’t create a block quote.

Isn’t this going to break some Markdown action somewhere?

I don’t think my specification for the output was NOT clear in at least these respects:

  1. Each of the recipients (TO, CC, and BCC) should contain the person’s full name as well as their email address. For example: “Dubious Duck”(dduck@disney.com)

  2. By Salutation, I meant a list of all the TO nicknames (separated by commas (“,”) except for the last one that should be preceded by “and”) and followed by a colon(“:”) and two new line characters. The Salutation should be at the very beginning of the BODY. Thus, each of the recipient constants must contain three elements: fullName, emailAddress, and nickname.

  3. The first line of the Draft, the HTML Title, correctly appears as the message SUBJECT. However, the URL does NOT appear in the BODY anywhere. It should appear right after the two new line characters (following the Salutation text) and itself be following by three new line characters.

  4. The webpage Selection, if present, should appear at the bottom of the BODY, after the three new line characters (following the URL). The Selection should be followed by two new line characters.

Here’s an example of a Spark message that I want created by the action:

— Begin Recipients —
TO: Scrooge McDuck (boo@disney.com), Minipherd Mouse (juno@disney.com), Mickalardio Mouse (sashi@disney.com)

CC: Dubious Duck (dduck@disney.com)
— End Recipients —

— Begin Subject —
titleOfWebPage
— End Subject —

— Begin Body —
Cheapskate, Mini, and Mickey:

webPageURL

selectionIfAny

— End Body —

Only from Safari.

No, this template controls what comes into Drafts, not what actions do to a draft.

No, same reason as above - it is for sharing into Drafts from Safari, which is not directly related to actions.

Only if you had created an action that was dependent on the structure of the data would this have any impact.

Either way, as long as all of the content is there, you could have an action process the draft to include/exclude the desired changes.

Can you share your modified action so we can provide some tips on how to modify what you have so far to do what you need? You can share an action to the action directory with the option to mark it as unlisted. That let’s you share a link here. Please ensure it is suitably sanitised - the names and e-mail addresses you used above are an ideal approach for not sharing actual contact details.

So far, I have NOT modified this action that FlohGro created (other than, of course, entering names and email addresses in the Recipient constants).

I did some rudimentary JavaScript coding back in the late ‘90s, but at this point I can barely read what FlohGro has written. Unfortunately, I’m not really capable of making significant changes to this action.

Okay, here’s a swing at an action that I think does almost everything you describe.

I use Spark on i*OS, but on Mac I use Mailmate, so I can’t test this on the Mac, only iPhone and iPad. When I run it on those, the body has the newline characters stripped from it. I have tried newlines, URL encoded newlines, %0d%0a, and all sorts of variations on a theme. But no luck. I wonder if it suffers the same issue as Gmail used to (and maybe still does)?

If you use it on the Mac, feel free to give it a try there, it may work. Someone else may have an idea how to get the newlines in another way. I suspect you may need to raise this with Readdle, who develop Spark.

The alternative for now would to to swap this line towards the end of the final script step:

// Body
cburlSpark.addParameter("body",`${strNicknameList}

${strPageURL}


${strPageSelection}`);

… to this …

// Copy body to clipboard so you can paste it into the e-mail body in the compose window
app.setClipboard(`${strNicknameList}

${strPageURL}


${strPageSelection}`);

One additional point:

You note that you want the recipient full names in the to field.

— Begin Recipients —
TO: Scrooge McDuck (boo@disney.com), Minipherd Mouse (juno@disney.com), Mickalardio Mouse (sashi@disney.com)

CC: Dubious Duck (dduck@disney.com)
— End Recipients —

These are for e-mail addresses. The names come from your contact’s information and is a convenience feature offered by e-mail client applications. Only the e-mail address is a valid entry, unless you have a richer interaction with an app such as through Shortcuts or the user interface - whereby contact names may allow for aliasing in a default e-mail address or being shown as associated with an entered e-mail address.

i.e. for what you are asking to do, the names are only useful for maintaining your recipient lists, and would not get used by the URL scheme process for creating an e-mail in Spark.

Hope that helps.

1 Like

This is very good and I am in awe of that regular expression that you used to insert “and” in the correct place in the Greeting string. Bravo!

The new line characters aren’t that big a deal. I’ll try asking Readdle about how to pass new line characters in their URL scheme.

But …

It looks like the Recipients (TO, CC, and BCC) are static as opposed to the pick list that FlohGro had.

I need a pick list.

1 Like

Combining those two actions seems totally possible - you would just need Prompt with the “pick list” from my shared actions and combine it with @sylumer’s Action.
Do you think you can do this by yourself?

If not - I’m happy to help but if yes - you’ll should go for it so you may be able to build the next script you need on your own :slight_smile:

Yes, I agree. I’ll take a swing at it this afternoon.

Thank you.

1 Like

I had thought the selection would be accomplished by multiple actions, but I get the point of wanting more flexibility of selection each time rather than predetermined selections- my oversight.

See how you get on, and if, and only if, you get stuck, maybe check out the amendment in the expandable section below to see if that helps any?

Amendment

Please do also post back if you get a response from Readdle in case others wanting to do something similar come across this discussion.

1 Like

I recall from some SMTP work I did in the late ‘90s that the protocol in fact allowed TO, CC, and BCC to be specified in the format “strFullName<strEmailAddress>”; see Section 3.4 of RFC 5322 for details on the syntax of email addresses.

So I tweaked your code just slightly to add the full name to the email address.

I changed each of the three instances of:

strInfow.split(",")[1].trim());`

To

strInfo.split(",")[0].trim()+"<"+
strInfo.split(",")[1].trim()+">");

And, viola, it works:

And Spark displays the names, not the email addresses. (And no, I do not have these recipients in my Contacts so Spark is not getting the names from there.)

1 Like

Well, I looked at your code and decided that it was much more elegant than anything I was going to come up with … so I used it.

However, I did have to study it pretty carefully in order to implement my tweaks to the recipient addresses; I’d never seen or used the map or join methods, for example. In the end, I did spend a few hours just to make and test my small change so I wasn’t completely lazy about it.

As you may know, Readdle is a Ukrainian company so I don’t expect to hear back from them any time soon. But if/when I do, I’ll post their response to this thread.

1 Like

Two days ago, I updated Spark Support Request {1640657} with the results of your coding. After describing what you tried doing with the Spark URL scheme for, I said:

Unfortunately, I’m having problems with properly encoding the parameter values for both recipient and body .

Questions:

  1. How can I encode both a name and an email address in TheirEmailAddress? I’m only able to add an address without a name.
  2. How do I encode new line characters in YourBodyText? All the ways I’ve tried to insert one or more new line characters have been ignored.

Thank you for your help.

Unfortunately, Readdle’s reply was not very helpful:

Thank you so much for taking the time and sharing this information with me.

Let me kindly note that we are not able to implement the outside created coding into Readdle apps.

Meanwhile, I may suggest you consider creating templates inside Spark, that may improve your workflow with the app.

Please don’t hesitate to contact me back if there is anything else I could do for you.

Have a wonderful day and stay safe!

So, no help with encoding new line characters in the bodyText. Moreover, the suggestion to use Spark’s Template feature is a nonstarter since Templates aren’t part of the URL scheme and so there’s no way to prefill them.

I’m afraid that I’m at a bit of a dead end.