Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Markup (HTML, XHTML, XML) _ create a button in a website for a form Email(subject and body done already)

Posted by: fregon Aug 4 2017, 11:45 PM

Hi,

I don't know if this is possible but I am trying to create button for my website that when pressed would create an outlook email.
Just like when you click an email address on a website would do.

The difference is that I don't want a blank email.
This is basically what I want to see in the email.
----------------------
From: (the customers email address, automatically inserted because it is the customers outlook)
To: (my email address that is inserted automatically by html code)
Subject: Questions regarding item stock (inserted automatically by html code)

Body: (inserted automatically by html code)
Please fill in the following questions.
Name:
Phone number:
email address:
item product number:
item product name:
Your question:

Thank you.
----------------------

So basically the customer just needs t fill in the email and press send.
Our email address, email subject and email body is ready from the beginning.

Could someone tell me how to create such a button please.


Posted by: CharlesEF Aug 5 2017, 12:50 AM

This would require a server side script to send the e-mail. First you would create a <form> with inputs for each field. You also need a submit button to send the data to the server script for processing. Don't forget you still need to validate your data, make sure required data is not left blank.

There are many ready to go 'Contact Us' scripts available on the web. You could modify one to fit your needs. Try a Google search.

Posted by: fregon Aug 5 2017, 01:22 AM

Thank you CharlesEF for your reply,

But I don't think you understood what I want.
Have you ever clicked a email address in a website, and then your outlook email opens up with that email address you clicked is inside the "To:" part?
But the subject and the body of the email is blank.
Well I would like it to be not a blank email.

Posted by: CharlesEF Aug 5 2017, 02:11 AM

Oh, sorry. I don't think you can do that with a button. In fact what you need is called a mailto link. You can use a <a>, like this:

CODE
<a href="mailto:someone@example.com?Subject=Hello%20again" target="_top">Send Mail</a>
This method only works if the user has a e-mail client installed on their computer. That is why it is better to use a web based 'Contact Us' form.

Posted by: fregon Aug 5 2017, 03:39 AM

Yes this is what I was looking for.
Thank you.
I didn't know about the mailto code.

I also found how to put messages into the body of the email by using this
&amp;body=The main text of the email is here" target="_top">Send Mail</a>

The thing is hat I want to make the body of the email to look like this:
Please fill in the following questions.
Name:
Phone number:
email address:
item product number:
item product name:
Your question:

But what I get looks like this:
Please fill in the following questions.Name:Phone number:email address:item product number:item product name:Your question:

Typing in <br> doesn't work since it just shows up into the email itself.

I knwo its a slim hope but is there a solution to this?






Posted by: pandy Aug 5 2017, 04:47 AM

You can use three parameters in the query string with mailto: subject, body and cc. So what you want can, technically, be done. Note that spaces and linebreaks need to be URL encoded though.

CODE
mailto:you@example.com?subject=Questions%20regarding%20item%20stock&body=Please%20fill%20in%20the%20following%20questions.%0D%0A%0D%0AName:%0D%0APhone%20number:%0D%0Aemail%20address:%0D%0Aitem%20product%20number:%0D%0Aitem%20product%20name:%0D%0AYour%20question:



That doesn't mean it will work. There must be en email client installed and the browser must be configured to use it. mailto has always been unreliable because of this (and more) and is so even more today when many people use webmail exclusively. Neither will it work if the user uses a public computer or someone else's machine. Well, in the last case it maybe will work, but it won't be the intended email account that's used.

As CharlesEF said, use a script if it is of any importance to you.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)