Compose Email In Studio


#1

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?


#2

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 :slight_smile:

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


#3

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();

});


#4

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);


#5

THANKS! This is perfect