Author |
Topic |
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 02 February 2005 : 18:50:29
|
Hi,
Hopefully you can help me. I have a simple contact form on a clients website, that sends the information to the clients email. What I'd like to do is to smarten up the email they'll receive, so it's all pretty colours etc. How would I insert HTML into the below, so I can specify the background colour, font colour etc etc?
<%
If Request.Form("btnSubmit").Count > 0 Then
' Create the message for the email
strMessage = "PTHMY - Contact Form" & VbCrlf & VbCrlf & VbCrlf
strMessage = strMessage & "Name: " & Request.Form("name") & VbCrlf & VbCrlf
strMessage = strMessage & "Email: " & Request.Form("email") & VbCrlf & VbCrlf
strMessage = strMessage & "Subject: " & Request.Form("subject") & VbCrlf & VbCrlf
strMessage = strMessage & "Info: " & Request.Form("info") & VbCrlf
' Create email object and set all the values, setting the from address to be the person who filled in the form
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = Request.Form("name")
Mailer.FromAddress= Request.Form("email")
Mailer.RemoteHost = "mrvnet.kundenserver.de"
Mailer.AddRecipient "PTHMY", "***@***.**.**"
Mailer.Subject = "PTHMY - Contact Form"
Mailer.BodyText = strMessage
' Send the mail and tidy up
if Mailer.SendMail then
' Redirect to thankyou page
Response.Redirect "thankyou.htm"
else
Response.Write "Mail send failure. Error was " & Mailer.Response
End If
End If
%>
Thanks for taking your time to look at this!
Oli |
Edited by - mortioli on 02 February 2005 18:51:19 |
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 03 February 2005 : 05:00:02
|
Essentially, what you're going to need to do is construct a complete HTML document within strMessage. That'll give you full control over everything but try and keep your HTML as simple as possible; most e-mail clients are absolute cack when it comes to rendering the more advanced stuff.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 03 February 2005 : 13:49:49
|
You mean something like this should work...
strMessage = "<html><body>" & VbCrlf
strMessage = strMessage & "<font color=#FF0000>" & VbCrlf
strMessage = strMessage & "PTHMY - Contact Form" & VbCrlf & VbCrlf & VbCrlf
strMessage = strMessage & "Name: " & Request.Form("name") & VbCrlf & VbCrlf
strMessage = strMessage & "Email: " & Request.Form("email") & VbCrlf & VbCrlf
strMessage = strMessage & "Subject: " & Request.Form("subject") & VbCrlf & VbCrlf
strMessage = strMessage & "Info: " & Request.Form("info") & VbCrlf
strMessage = strMessage & "</font>" & VbCrlf
strMessage = strMessage & "</body></html>" & VbCrlf
|
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 04 February 2005 : 05:37:05
|
Exactly
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 05 February 2005 : 05:32:51
|
I tried the above, and it shows up like this when viewing in Hotmail;
PTHMY - Contact Form Name: oli Email: ***@hotmail.com Subject: test Info: 123
But this when viewing the same email in Outlook Express;
<html><body>
<font color=#FF0000>
PTHMY - Contact Form
Name: oli
Email: ***@hotmail.com
Subject: test
Info: 123
</font>
</body></html>
Any ideas? Hotmail seems to like the colours, but not the line breaks, whereas Outlook likes the breaks, but not the colours |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 05 February 2005 : 11:37:28
|
Try using <br /> instead of vbCrlf to solve the line break issue. You might need to specify in your e-mail object that it's a HTML mail to get around the OE problem.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
mortioli
Average Member
United Kingdom
898 Posts |
|
Hamlin
Advanced Member
United Kingdom
2386 Posts |
Posted - 06 February 2005 : 08:18:00
|
Before the Mailer.BodyText put this: Mailer.ContentType = "text/html |
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 07 February 2005 : 18:15:59
|
*thumbs up* spot on, cheers!
Another question...
The site is for a band, so they've got an email for each member (4), and one for the whole band. How would I go about putting a drop down box on the contact form, to choose who you'd like the form to be sent to, then when you hit submit, it'd send to that person? |
Edited by - mortioli on 07 February 2005 19:55:31 |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 08 February 2005 : 05:47:09
|
Add a select to the form as you normally would, gving each option a numerical value (starting from 0).
When sending the mail, before adding the recipients, create an array of the 5 e-mail addresses, in the same order as their option values in the select.
Then, instead of adding the recipient directly, grab the relevant address from the array.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 15 February 2005 : 15:18:19
|
I get the general idea of what you're explaining, but I've looked around on Google etc, and can't seem to make head or tail of where to start.
I'm quite useless when it comes to ASP at the moment Would you be able to give me an example please? Sorry. |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 16 February 2005 : 07:12:17
|
In your form, add a select element as below:
response.write "<select name=""address"">"&_ "<option value=""0"" selected=""selected"">name1</option>"&_ "<option value=""1"">name2</option>"&_ "</select>"
Then, when processing the form, before adding the recipient to your mail object, add something like:
arrAddresses=array("address1","address2") strAddress=arrAddresses(clng(request.form("address")))
Then you can use the strAddress variable and assign it as the recipient in your mail object.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
|
Topic |
|