DEV Community

etcroot
etcroot

Posted on

Dynamically Using mailto:

If you want to use mailto: tag when you're handling emails you can do this simple trick to make life easier for the consumers.

Been using mailto: the normal way until I found out you can actually customize it way more.

Here's what I use for my site (Slightly edited to not advertise)

`mailto:${contact}?subject=Application for ${title}&body=Hi ${username}, I am interested in your listing for ${title} that I found listed on [R E D A C T E D]. I would like to know more about it.`
Enter fullscreen mode Exit fullscreen mode

The queries you're able to use are:

  • mailto: (to set the recipent, you can separate this with commas)
  • &subject= (this will set the subject for the email, use URL encoding if you're sending long messages)
  • &body= (Same as subject but instead you're setting the actual email message)
  • &cc= (Setting CC recipents)
  • &bcc (Setting BCC recipents)

Hope this helped!

Top comments (0)