Need Spark Action that Sends Copies

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.

►First thought … CRLF (%0d%0a) is a Windows encoding. Did you try the unix encoding, LFLF (%0A%0A)?

►Second thought … Instead of URL Encoding CRLF or LFLF, what about URL Encoding the HTML Entity for new line, &NewLine?

►Third thought … Since I have set Spark as my default mailer, might using the mailto: URL scheme get around whatever the problem is with the Spark URL scheme?

mailto:toAddress?cc=ccAddress&bcc=bccAddress&subject=theSubject&body=theBodyFirstLine%0A%0AtheBodySecondLineAfterBlankLine

UPDATE April 21, 2022 3:55 AM

:eyes:! The mailto: worked!

2 Likes

I remember I had tried %0A, as well as <br>, and \n to get a single new lin. It looks like using mailto: is the key :clap:t2:

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

That response feels like it might be an email template itself from a first line support person who didn’t understand what was being requested. I cannot believe it is not possible for them to decode a newline from a URL scheme given what they already have in place.

I wonder if mailto: would also be a way to get new lines into the body of Gmail.app? :thinking: The internet is awash with posts of people asking how to do so with the Gmail URL scheme.

I responded by pointing out that Readdle supports URL schemes for PDF Expert and their calendar, so why not Spark. Maybe my response will kick the problem up to a higher level support person. :man_shrugging:t2:

1 Like

This new line issue with URL schemes is a pretty common problem with Mail clients. Most of them default to composing/sending HTML email these days, and don’t do the necessary conversions on their incoming text.

I think the Gmail app, Spark, Airmail, Outlook, and others have all either had or have this bug – and some have repeatedly fixed, and then broken it again over the years. :man_shrugging:

Even Apple screwed this up briefly last year in the Mail share extension. In the late versions of iOS 14.x, if you sent text to the Mail compose APIs or the mailto: URL it would pop up in the message with literal text Line1<BR>Line2<BR>!

Yes, during last night’s search for a solution, I stumbled upon this problem with Apple’s Mail.app for iOS.

I also read that mailto: is notoriously unreliable when it comes to including multiple email addresses in any of its recipient lists, i.e., to, cc, or bcc but I haven’t tried this yet.

So, mailto: may not really be the solution for my mailer need.

Here’s this morning’s response from Readdle:

Thank you so much for your emails and provided information. Let me apologize for the misunderstanding.

I’ve just double-checked the information with our Quality Assurance team and would like to let you know the URL scheme, indeed, is available in Spark. However, the new line characters in the body text feature is not supported at the moment.

Please be assured that I’ve added your kind request to our Wish List for the developers to look through and keep in mind for further investigation of the matter. Once there is any update on the matter - I’ll be happy to let you know.

Also, if you have the Spark app set as your default mail client on your device, please consider using the mailto: link, as it will work the same way as the URL scheme.

For example, "mailto:one@test.email,two@test.email?subject=test&body=some%0Atext&cc=three@test.email", where %0A is the new line character.

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

So, apparently they are recommending using mailto: instead of the Spark URL scheme.