[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

How to controle fonttype/layout in E-mail send by webpage form?

Hi,

On my website I have a Contact-form. On this form my cliënts can enter their name/adres/etc..
This information is currently send to me by mailto:
The text in this email is always send as Times New Roman and the layout is far from professional.

Is it possible to controle the fonttype of the email to be send?
Is there a way to controle the layout of the send E-mail. Maybe sending a HTML-email is an option?
How to compose this layout based on the information from the Contact-form?

Thank you for your help,
Stef
0
Stef Merlijn
Asked:
Stef Merlijn
  • 8
  • 7
  • 3
  • +1
3 Solutions
 
Richard QuadlingSenior Software DeverloperCommented:
Hi Delphiwizard,


If you supply just plain text then the rendering will depend upon the client reading the email. If they read it using a webmail viewer, then the font may be anything and at any size.

To send email as HTML you need to have the appropriate header.

I use PHP and have the following headers ...

MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1

Then my body/message is normal HTML


Regards,

Richard Quadling.
0
 
Stef MerlijnDeveloperAuthor Commented:
But how do I add the entered information (on the contact-form) into a HTML layout? And send it by E-mail?
0
 
Richard QuadlingSenior Software DeverloperCommented:
What code do you have to send the email at the moment.

Normally you have a mail function which requires From, To, Subject, Message.

You would normally also have AdditionalHeaders.

MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1

would be the additional headers.

They will need to be terminated with

CRLF
0x0D 0x0A
\r\n
chr(13) & chr(10)

sort of thing (hopefully one of those formats is meaningful to you).


0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
Stef MerlijnDeveloperAuthor Commented:
On my HTML webpage I have a form with a submit-button.
To the form the following is added:
<form action="mailto:my@email.nl" method=POST enctype="text/plain" name="InfoAanvraag" style="font-family: Arial; font-size: 10pt">

On the form there are several fields that must be entered by the cliënt.
After pressing the submit-button, the content of the form must be send to my@email.nl
0
 
Richard QuadlingSenior Software DeverloperCommented:
Ah. I see. There is no way to extend this mechanism as the emailing is done by the local client and NOT the server.

You have to use a server side script to construct the message (in html) with the appropriate headers.
0
 
Richard QuadlingSenior Software DeverloperCommented:
As you are using FrontPage, does your server have FrontPage Extensions? If so, there is probably an extension you can use to do this. I don't know about them though, I use PHP.
0
 
Stef MerlijnDeveloperAuthor Commented:
I can use PHP, frontpage extensions, ASP, CGI, you name it.
So any solution would be perfect.
0
 
Richard QuadlingSenior Software DeverloperCommented:
Then I would get hold of phpmailer (I think it is called).

0
 
Stef MerlijnDeveloperAuthor Commented:
Can it be used on a windows-server?
0
 
Richard QuadlingSenior Software DeverloperCommented:
PHP can be used in Apache, Sambar and even IIS (grin) and many other windows based web servers.

Then using phpmailer you will be able to generate html mime emails and send them.
0
 
coreybryantCommented:
You cannot use Frontpage to do what you want.  You have to use another processor - check first with your hosting company to see what they support - JMail, ASPMail, ASPEmail, etc.  

-Corey
0
 
Stef MerlijnDeveloperAuthor Commented:
I've asked my webhost for PHPMailer and ASPMail.
They will get back to me.
JMail I will check also.
0
 
Richard QuadlingSenior Software DeverloperCommented:
FP extensions are server side aren't they?
0
 
Stef MerlijnDeveloperAuthor Commented:
Yes.
0
 
Richard QuadlingSenior Software DeverloperCommented:
FrontPage Mail Extensions:

FrontPage mail extensions are used by FrontPage to be able to send mail directly from forms created by FrontPage's webbot component.


Ask them if they support this. This should mean you can configure it all in FrontPage.
0
 
coreybryantCommented:
>RQuadling
>>FP extensions are server side aren't they?

FPSE are not a server side language.  It is a program to help people use FP and make it easier to build a website.

You cannot configure the email that is sent using FP.  You have to use the components I suggested

-Corey
0
 
bigbillydotcomCommented:
Hey Delphi -  you are going to have to do some active server pages to do what you want
asp can use a server object called CDO to send email from asp pages
CDO will give you the flexibility to create and send your own custom emails
without relying on the front page "emailto" form method

**********************************************
Skip the following step if you arte using a webhost
****************************************
First - make sure your SMTP server on that box is configured correctly
check this link
http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21512716.html
***********************************************************

Cnce that is done, here are two simple-sample ASP pages as an example
of how to create and send an email from ASP
check your hosting company for mroe info re: settings for the smtp server
you can access from ASP

save them to your website then test with TicketForm.asp first

*******Save as TicketForm.asp***********
<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>

<form name="thisForm" method=post action="TicketEmail.asp">
<table border=1 align=left>
     <tr>
          <td>
               First Name:&nbsp;
          </td>
          <td>
               <input type="text" name=firstname id=firstname>
          </td>
     </tr>
     <tr>
          <td>
               Last Name:&nbsp;
          </td>
          <td>
               <input type="text" name=lastname id=lastname>
          </td>
     </tr>
     <tr>
          <td>
               Email Address:&nbsp;
          </td>
          <td>
               <input type="text" name=email id=email>
          </td>
     </tr>
     <tr>
          <td>
               Problem:&nbsp;
          </td>
          <td>
               <TEXTAREA rows=2 cols=20 id=problem name=problem></TEXTAREA>
          </td>
     </tr>
     <tr>
          <td colspan=2>
               <INPUT type="submit" value="Submit" id=submit1 name=submit1>
          </td>
     </tr>          
</table>          

</form>

</BODY>
</HTML>

***********Save as TicketEmail.asp*************
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>


<%
'create variables to get data from request page
dim fname,lname,email,problem,UserInfo

'get firstname from form submitted
fname = Request.Form("firstname")
'get lastname from form submitted
lname=Request.Form("lastname")
'get email from form submitted
email=Request.Form("email")
'get problem from form submitted
problem=Request.Form("problem")
'create a valid From Address
UserInfo = fname+" "+lname+" ("+email+")"

'Set config variables for CDO object

Const cdoSendUsingMethod        = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort          = 2
Const cdoSMTPServer             = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort         = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout  = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate       = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic                  = 1
Const cdoSendUserName           = "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword           = "http://schemas.microsoft.com/cdo/configuration/sendpassword"

Dim objConfig  ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields     ' As ADODB.Fields

' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
     .Item(cdoSendUsingMethod)       = cdoSendUsingPort
'typically add your server ip address below    
     .Item(cdoSMTPServer)            = "your_server_ip_here"
     .Item(cdoSMTPServerPort)        = 25
     .Item(cdoSMTPConnectionTimeout) = 10
'if you have to authenticate to send your email, uncomment and fill out lines below    
'    .Item(cdoSMTPAuthenticate)      = cdoBasic
'    .Item(cdoSendUserName)          = "username"
'   .Item(cdoSendPassword)          = "password"
     .Update
End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
'hard code the full email address below of who this is going to
     .To       = "your@emailhere.com"
'from line comes from the form submitted UserInfo variable
     .From     = UserInfo
'replace with whatever subject you want
     .Subject  = "Ticket Request"
'problem ine comes from the form submitted problem variable    
     .TextBody = problem
     .Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing

'show sending confirmation
dim resultsvar
resultsvar = "Email sent re:<br>"
resultsvar = resultsvar +"From User:&nbsp;"+UserInfo+"<br>"
resultsvar = resultsvar +"Problem:&nbsp;"+problem+"<br>"

Response.Write resultsvar

%>


</BODY>
</HTML>
0
 
Stef MerlijnDeveloperAuthor Commented:
ASPEmail is installed on the server of my webhost, so that opens new possibilities.
I will do some testing with that.
Thank you all for your help.
0
 
coreybryantCommented:
You can check out their manual: http://www.aspemail.com/manual.html for coding example

-Corey
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 8
  • 7
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now