English 中文(简体)
我能否确定使用邮寄电子邮件的主题/内容?
原标题:Can I set subject/content of email using mailto:?

在我使用邮件时,能否确定电子邮件的主题/内容?

最佳回答
问题回答
<a href="mailto:manish@simplygraphix.com?subject=Feedback for 
webdevelopersnotes.com&body=The Tips and Tricks section is great
&cc=anotheremailaddress@anotherdomain.com
&bcc=onemore@anotherdomain.com">Send me an email</a>

您可使用该守则确定主题、机构、职业、职业或职业。

mailto:joe@company.com?subject=Your+subject

我将其分成两条线,使其更加可读。

<a href="

    mailto:johndoe@gmail.com

    ?subject=My+great+email+to+you

    &body=This+is+an+awesome+email

    &cc=janedoe@gmail.com

    &bcc=billybob@yahoo.com

">Click here to send email!</a>

here is the trick http://neworganizing.com/content/blog/tip-prepopulate-mailto-links-with-subject-body-text

<a href="mailto:tips@neworganizing.com?subject=Your+tip+on+mailto+links&body=Thanks+for+this+tip">tell a friend</a>

是的。

mailto: email@host.com?subject=something

这里是一个可操作的幻灯塔,帮助你生成邮件:与任择主题和机构的联系。

function generate() {
  var email = $( #email ).val();
  var subject = $( #subject ).val();
  var body = $( #body ).val();

  var mailto =  mailto:  + email;
  var params = {};
  if (subject) {
    params.subject = subject;
  }
  if (body) {
    params.body = body;
  }
  if (params) {
    mailto +=  ?  + $.param(params);
  }

  var $output = $( #output );
  $output.val(mailto);
  $output.focus();
  $output.select();
  document.execCommand( copy );
}

$(document).ready(function() {
  $( #generate ).on( click , generate);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="email" placeholder="email address" /><br/>
<input type="text" id="subject" placeholder="Subject" /><br/>
<textarea id="body" placeholder="Body"></textarea><br/>
<button type="button" id="generate">Generate & copy to clipboard</button><br/>
<textarea id="output">Output</textarea>

如果您想在电子邮件中添加html的内容,则发送传真机的“url encode their html”代码,并将其列入您的邮件链接代码,但问题在于,你可以将这种链接的电子邮件类型从平原文本上排到html,用户使用这一链接,需要其邮件客户在缺席时发出html电子邮件。 如果你想在这里测试的是简便邮件链接的代码,其图像在链接中总结(为可见度而添加的单体风格镜):

<a href="mailto:?body=%3Ca%20href%3D%22{{ scope.url }}%22%3E%3Cimg%20src%3D%22{{ scope.url }}%22%20width%3D%22300%22%20%2F%3E%3C%2Fa%3E">

The html tags are url encoded.

你只是需要一份简单的超文本文件。

<a href="mailto:email@example.com?subject=This is a subject&body=This is body">Send an email</a>

供邮件使用的动态链接比以下代码:

        const formConsultation = document.querySelector( form#form-consultation );
        formConsultation.addEventListener("submit", function(evt) {
            evt.preventDefault();
            var targetobj = evt.target;
            var actionUrl = targetobj.action;
            var message = targetobj.message.value;
            if (actionUrl && actionUrl != "#" && message) {
                var newBodyMsg = subject = "";
                var username = targetobj.username.value;
                var useremail = targetobj.useremail.value;

                if (targetobj.subject.value && targetobj.subject.value.trim().length > 0) {
                    subject = targetobj.subject.value;
                }

                if (username.trim().length > 0) {
                    newBodyMsg += "Hi! my name is " + username + ".";
                }
                if (useremail.trim().length > 0) {
                    if (newBodyMsg.length > 0) {
                        newBodyMsg += " & ";
                    }
                    newBodyMsg += "my email address is " + useremail + ".";
                }

                if (newBodyMsg.length > 0) {
                    newBodyMsg += "

 ";
                }
                newBodyMsg += message;
                window.open(actionUrl + "?subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(newBodyMsg));
            }
        });
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">

<body>
  <div class="container">
    <form action="mailto:example@test.com" method="get" enctype="text/plain" class="form-consultation" id="form-consultation">
      <div class="mb-3">
        <label class="form-label">Name</label>
        <input type="text" class="form-control" name="username" placeholder="Your Name" required>
      </div>
      <div class="mb-3">
        <label class="form-label">Email</label>
        <input type="email" class="form-control" name="useremail" placeholder="Your Email address" required>
      </div>
      <div class="mb-3">
        <label class="form-label">Subject</label>
        <input type="text" class="form-control" name="subject" placeholder="Subject" required>
      </div>
      <div class="mb-3">
        <label class="form-label">Message</label>
        <textarea cols="30" rows="3" class="form-control" name="message" placeholder="Message" required></textarea>
      </div>
      <button type="submit" class="btn btn-primary">Send A Message</button>
    </form>
  </div>
</body>

OR Using Jquery

$( #form-consultation ).submit(function() {
    event.preventDefault(); // this will prevent the default submit

    var actionUrl = $(this).attr( action );
    var message = $(this).find("textarea[name=message]");
    if(actionUrl && actionUrl != "#" && message) {
        var newBodyMsg = subject = "";

        var username = $(this).find("input[name=username]").val();
        var useremail = $(this).find("input[name=useremail]").val();
        if(username.trim().length > 0) {
            newBodyMsg += "Hi! my name is " + username + ".";
        }
        if(useremail.trim().length > 0) {
            if(newBodyMsg.length > 0) {
                newBodyMsg += " & ";
            }
            newBodyMsg += "my email address is " + useremail + ".";
        }

        if (newBodyMsg.length > 0) {
            newBodyMsg += "

 ";
        }
        newBodyMsg += message.val();
        window.open(actionUrl + "?subject="+ encodeURIComponent(subject) +"&body=" + encodeURIComponent(newBodyMsg));
    }
    
    return false;
});

<>0>NOTE:在您的系统中高于代码。 如果你试图在座标上行码(头盔),那就比起工作。 流入。 因此,请在你的地方系统中测试这一守则。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签