Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I would like to assign the values of my HTML form like
First name
Last Name
Email Address
Message
to the email after clicking the send Email button

I have tried using the below script it joust opens the mail in Outlook but not copying the HTMl data
can I know what I need to add to my script for copying those details to the email when submit the send buton

What I have tried:

function sendEmail()
{
    var link = "mailto:abcd@smtp.com" +
        "&subject=" + escape("This is subject") +
        "&body=" + escape("This is body");
    var name = document.getElementById("First Name")

    window.location.href = link;
}
Posted
Updated 9-Aug-18 2:36am
v2
Comments
Nathan Minier 9-Aug-18 8:27am    
You'll need something on the backend to accept the form data and format it for SMTP. Then you need to have a registered mail server (or have a public gateway that isn't blocked by literally everyone) to pass the message through.
Member 13886349 9-Aug-18 8:40am    
Hi,
Thanks fro your reply,
HTML form submission in on client side and SMTP configured on server side.
I have no idea as technically how it should work when client side user submits the forms.
Nathan Minier 9-Aug-18 8:53am    
You don't use a mailto: link, because that's what opens the email client, you would need to submit the form and have an active server capability on the server that would format for SMTP, or use a special javascript library on the client side, but I would not advise that approach as it would require a completely open SMTP forwarder, and those are generally untrusted downstream.
Member 13886349 9-Aug-18 9:03am    
Hi Thanks for your reply,
Do you have any example code links on this portal like submit the form without mailto:link
Mohibur Rashid 10-Aug-18 3:26am    
Have you ever heard of bing? or perhaps google?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900