Is there a way to use a mailto: link that includes a timestamp or some sort of unique code?

ぐ巨炮叔叔 提交于 2021-01-28 19:23:45

问题


I'd like to have a link like so:

mailto:foo@bar.com?subject=email&body=TIMESTAMP

or

MATMSG:TO:example@example.com;SUB:email;Body:TIMESTAMP;;

But in the subject line or in the body, I'd like it to include any of these options:

  1. A timestamp
  2. Sort of message like 'Message number #' which counts the number of times it's been used
  3. Any sort of unique random code of gibberish

I was hoping it would be possible to somehow import the contents from another website like this or something. Is there any way to do this using a stand alone link? Ultimately, I'm hoping this link can used with a QR code.

Thanks in advance.


回答1:


At a glance I think there are 2 ways to do that:

  • generate the link with javascript:

    document.write('<a href="mailto:foo@bar.com?subject=email_' + new (Date().getTime()) + '"></a>');
    
  • or generate the link with server side scripting, for example PHP:

    <?php
        echo "<a href="mailto:foo@bar.com?subject=email_".round(microtime(true))."</a>"
     ?>
    

Personally I would use javascript, I think it's more appropriate for this kind of stuff.

Edit:

Even better is using a javascript bookmarklet, that way it can be used as a link:

javascript:location.href='mailto:example@example.com?SUBJECT=Data&BODY=Code:'+new Date().getTime()



来源:https://stackoverflow.com/questions/23163418/is-there-a-way-to-use-a-mailto-link-that-includes-a-timestamp-or-some-sort-of-u

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!