-2

I want to include a timestamp in the subject of a mail. I already found out that I have to use javascript for this, I also found a way to include it, but I have trouble displaying the mail adress on the webpage (nothing is displayed). Below is the code I wrote until now. I think it has to do something with the way I included html in my javascript, but I can't find my error.

    <script> 
Document.write('<a href="mailto:example@example.de?subject=This is my subject' + new (Date().getTime())+'">example@example.de</a>);
</script>

The snippet of code I used is this one:

document.write('<a href="mailto:foo@bar.com?subject=email_' + new (Date().getTime()) + '"></a>');
Cyhiraeth
  • 15
  • 6
  • 2
    The *first* letter of the script! JavaScript is case-sensitive! Open the developer tools in your browser and read the error messages. – Quentin Oct 28 '19 at 15:05

2 Answers2

0

A possible solution can be:

'<a href="mailto:foo@bar.com?subject=email_' + Date.parse(Date()) + '"></a>'
tcconstantin
  • 126
  • 3
0

You really shouldn't be doing this, for two reasons:

It's better to send mails from your webserver which would also solve your subject problem.

RoToRa
  • 34,985
  • 10
  • 64
  • 97
  • Thank you for your response! I know that mailto is somewhat old, but because of the General Data Protection Regulation in the EU, formulars and other "regalur" contacting methods are a bit difficult to implement, so people are now actually going back to this! This is the reason I was using mailto in the first place! – Cyhiraeth Oct 29 '19 at 14:18