Mailto on dynamic page code not working

Hey all, I have very little developer knowledge but am trying to figure this out myself and could use some help.
I am trying to code a mailto into a dynamic page that will pull the relevant email address from the linked collection. I’ve pieced this code together from other posts in the community, but I dont really know what I’m doing and would appreciate some advice.

Collection ID: daynamicDataset
field key: email
button ID: emailButton

Code:
export function emailButton_click ( event ) {
import wixLocation from ‘wix-location’ ;

$w . onReady ( () => {
$w ( ‘#emailButton’ ). onClick ( () => {
const email = ( “mailto:” + email );
wixLocation . to ( email );
});
});

}

You can’t use wixLocation.to(email).
See here how to use mailto ;
https://www.wix.com/velo/forum/main/comment/c8415cfe-ac44-48f6-91a6-1d53ea5fd216?postId=631cdbddd6c9b60012924e58

thank you :slight_smile: I’ve added this to my own site and have modified for my needs and it isnt working:

You need to change the elements IDs to your own element IDs (via the property panel).

  • you forgot the # symbol

Also, it will only work if you connected the site to your own domain

hello, yes my domain is connected. I’m changing the ID’s but there are several that I’m unsure what to replace with:
mailto: ${ emailAddress } - should the be the field key?
‘email-details’ - I’m not sure what this refers to?

 const info = {
  subject: PUT_THE_SUBJECT_STRING_HERE,
  body: PUT_THE_BODY_STRING_HERE,
  emailAddress: PUT_THE_RECEPIENT_EMAIL_HERE,
  timestamp: Date.now()
};