# Mailto on dynamic page code not working

**URL:** <https://forum.wixstudio.com/t/mailto-on-dynamic-page-code-not-working/35411>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [September 15, 2022, 12:23pm UTC](https://forum.wixstudio.com/t/mailto-on-dynamic-page-code-not-working/35411 "2022-09-15T12:23:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jennaedgar](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/jennaedgar/32/34486_2.png) [@jennaedgar](https://forum.wixstudio.com/u/jennaedgar)\
**Post date:** [September 15, 2022, 12:23pm UTC](https://forum.wixstudio.com/t/mailto-on-dynamic-page-code-not-working/35411/1 "2022-09-15T12:23:41Z")

</div>

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

}

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [September 15, 2022, 4:18pm UTC](https://forum.wixstudio.com/t/mailto-on-dynamic-page-code-not-working/35411/2 "2022-09-15T16:18:48Z")

</div>

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](https://www.wix.com/velo/forum/main/comment/c8415cfe-ac44-48f6-91a6-1d53ea5fd216?postId=631cdbddd6c9b60012924e58)

---

<div class="post-metadata">

**Author:** ![jennaedgar](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/jennaedgar/32/34486_2.png) [@jennaedgar](https://forum.wixstudio.com/u/jennaedgar)\
**Post date:** [September 15, 2022, 7:23pm UTC](https://forum.wixstudio.com/t/mailto-on-dynamic-page-code-not-working/35411/3 "2022-09-15T19:23:44Z")

</div>

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

 ![](https://us1.discourse-cdn.com/wix/original/3X/7/1/71c0d810d674d39602532143d023b7c459c0dedf.png)

 ![](https://us1.discourse-cdn.com/wix/original/3X/7/8/78747f6eed794b61b4e5ec926ecb0aad6556ddaf.png)

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [September 15, 2022, 7:36pm UTC](https://forum.wixstudio.com/t/mailto-on-dynamic-page-code-not-working/35411/4 "2022-09-15T19:36:55Z")

</div>

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

- you forgot the # symbol

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [September 15, 2022, 7:37pm UTC](https://forum.wixstudio.com/t/mailto-on-dynamic-page-code-not-working/35411/5 "2022-09-15T19:37:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jennaedgar](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/jennaedgar/32/34486_2.png) [@jennaedgar](https://forum.wixstudio.com/u/jennaedgar)\
**Post date:** [September 15, 2022, 8:44pm UTC](https://forum.wixstudio.com/t/mailto-on-dynamic-page-code-not-working/35411/6 "2022-09-15T20:44:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [September 15, 2022, 9:16pm UTC](https://forum.wixstudio.com/t/mailto-on-dynamic-page-code-not-working/35411/7 "2022-09-15T21:16:20Z")

</div>

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

```
