I know there is a compose email action in designer but I’m working in Studio. Is there a way to have that same function here?
Hey Molly!
This should be fairly simple to implement. The implementation depends on the content of the email that you want to pre-fill and which you want left up to the user.
The best way to replicate the way it is performed in Designer is to create a button in Studio with a pointerdown event on it. The URL for an email then follows this format: "mailto:someone@example.com"
The relevant docs page is here: https://docs.zap.works/studio/scripting/examples/launching-website/
More information on email links are here: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_link_mailto
Below is what the pointerdown script should resemble
parent.on(“pointerdown”, (e) => {
// Runs when pointerdown occurs on the parent node
// The argument e contains useful info about this event:
// https://docs.zap.works/studio/scripting/reference/object/events/pointerdown/
Z.device.launchUrl("mailto:someone@example.com", false);
});
Give me a shout if you have any further questions or if you encounter any difficulties.
Cheers,
Chris
Doing a similar thing here. I’m trying to collect user info via a prompt and then pass it to an email that is sent automatically (maybe to a database?). I can’t figure out how to call the z.promt-gathered “string” (I’m just using “theirEntry”) into the Subject of the email…
Here’s what I have:
var nameprompt = Z.Prompt({
title: “Hello”,
text: “Please enter your name:”,
defaultValue: “Dog”,
maxLength: 12,
filterProfanity: true
});
nameprompt.on(“confirm”, function(theirEntry : string) {
console.log(“They entered: " + theirEntry);
});
nameprompt.on(“cancel”, function() {
console.log(“They cancelled the dialog :-(”);
});
Z.device.launchUrl("mailto:jordandreyerteacher@gmail.com?Subject=theirEntry%20got%20Venusaur”, false);
parent.on(“pointerdown”, (e) => {
// Runs when pointerdown occurs on the parent node
// The argument e contains useful info about this event:
// https://docs.zap.works/studio/scripting/reference/object/events/pointerdown/
nameprompt.show();
});
Hi,
First, use a global variable to store theirEntry:
userName = theirEntry;
Then, use the concatenation operator (+) for the launchUrl parameter:
"mailto:jordandreyerteacher@gmail.com?Subject=" + userName + "%20got%20Venusaur”, false);
THANKS! This is perfect
I can’t get this to work. I’m using a simple mailto
link, but nothing happens when I tap the icon on my iPhone when previewing the zap. Should this work across devices?
EDIT: Ok, it’s working without the “subject” query string parameter. I’ll have to take a closer look at that.
EDIT 2: It’s working now. Be sure to use the encodeURIComponent()
function for the subject line if you’re accepting user input for that value. In my case, I created a subsymbol template for an “email us” button, and I allow the Zap dev to input both an email address and subject line.