Mailto in collection?

This might be stupidly simple; I’m not a coder so help would be super appreciated. I’ve created a dynamic profile page for individual “Members” and am including an email contact link for them.

Making “Email” a text field in the Members database obviously only displays the email as text on the dynamic page; I’d like it to be a mailto that launches the user’s email client.

I tried creating a button and linking it to the field, but obviously that still just links to text, not to a mailto link.

Seems really simple and I’m probably showing massive incompetence. But … Anyone able to help?

Hi Dan,

Welcome to the Wix Code forums.

There are a number of ways to set up an email link, but for a direct and easy way to do this, take a look at the link property of the Button component . That should get you started in the right direction. Then as you learn more about Wix Code you can be more creative and use other techniques.

Good luck,

Yisrael

Thanks Yisrael. The issue I’m dealing with is that it’s a dynamic page I’ve created, that displays the email from a member in a database; it seems that:

  1. mailto can only be entered as a URL field type
  2. the URL field in the database can only take “mailto:” and not the additional code for subject lines, CC etc.?

You can retrieve email from database and then use

const email = FETCH_EMAIL_FROM_DATABASE;
$w("#MY_BUTTON_ID").link = 'mailto:' + email;

I’m wondering about the same thing, where I want a button linked to a database field for a mailto, and the subject depends on the row in the database

mailto is the email address URL. To supply the subject line just use other appropriate fields from the row in the collection. CC would be other email addresses - that is, URLs.

Good luck

As a non-coder this is not enough info for me. What about adding the “email” functionality as part of the collection field, so that an email address from the “email” column in the database becomes automatically clickable and activates the email client on the dynamic page. This function is available for non-dynamic buttons. It should be on dynamic pages also.

Thanks for your time

Hi I have the same issue did you find a way to solve it?

$w("#dynamicDataset").onReady(() => {
 const item = $w("#dynamicDataset").getCurrentItem();
 if (item.email)
    $w("#button").link = "mailto:"+ (item.email) 
})
1 Like

Instead of showing each email in the database to its corresponding item, it is only showing the same email for every item. Does anyone know why?