简体   繁体   中英

Open Outlook and preset email, subject and body using HTML/Javascript

I am new in Javascript and I would like to make a small offline tool that opens up Outlook, and presets the email in the "To" section, presets the default Subject, and presets the body of the email with text from a textarea.

I would need the text area so that I can modify the email content whenever I want.

For now, I have the following code:

<form method="post" action="mailto:yourname@yoursite.com" enctype="text/plain">
   <input type=text name=your_content>
   <input type=submit value="Submit Your Content">
</form>

However, when I submit, Outlook opens, and the name attributes' values appear before my text.

Is there a way to avoid adding the name's value in my email, replace input with textarea and add the above mentioned things?

Thanks!

Try switching the method to GET so it behaves more like an anchor tag and puts your values into url parameters instead of a post body. You will have to set the input names to valid mailto: values like body & subject

<form method="GET" action="mailto:yourname@yoursite.com" enctype="text/plain">
   <input type=text name="body">
   <input type=submit value="Submit Your Comments">
</form>

note that there is a max url size of ~2k characters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM