Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Email Form - HTML
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

mortioli
Average Member

United Kingdom
898 Posts

Posted - 02 February 2005 :  18:50:29  Show Profile  Visit mortioli's Homepage  Send mortioli an AOL message  Send mortioli a Yahoo! Message
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  Show Profile
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.”
Go to Top of Page

mortioli
Average Member

United Kingdom
898 Posts

Posted - 03 February 2005 :  13:49:49  Show Profile  Visit mortioli's Homepage  Send mortioli an AOL message  Send mortioli a Yahoo! Message
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
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 04 February 2005 :  05:37:05  Show Profile
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.”
Go to Top of Page

mortioli
Average Member

United Kingdom
898 Posts

Posted - 05 February 2005 :  05:32:51  Show Profile  Visit mortioli's Homepage  Send mortioli an AOL message  Send mortioli a Yahoo! Message
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
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 05 February 2005 :  11:37:28  Show Profile
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.”
Go to Top of Page

mortioli
Average Member

United Kingdom
898 Posts

Posted - 05 February 2005 :  17:42:14  Show Profile  Visit mortioli's Homepage  Send mortioli an AOL message  Send mortioli a Yahoo! Message
How do I specify HTML?

I came across these two pages of info;

http://www.burtonnetworks.com/support/cdonts/
http://www.powerasp.com/content/hintstips/asp-email.asp

...but still getting my knickers in a twist
Go to Top of Page

Hamlin
Advanced Member

United Kingdom
2386 Posts

Posted - 06 February 2005 :  08:18:00  Show Profile
Before the Mailer.BodyText put this: Mailer.ContentType = "text/html
Go to Top of Page

mortioli
Average Member

United Kingdom
898 Posts

Posted - 07 February 2005 :  18:15:59  Show Profile  Visit mortioli's Homepage  Send mortioli an AOL message  Send mortioli a Yahoo! Message
*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
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 08 February 2005 :  05:47:09  Show Profile
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.”
Go to Top of Page

mortioli
Average Member

United Kingdom
898 Posts

Posted - 15 February 2005 :  15:18:19  Show Profile  Visit mortioli's Homepage  Send mortioli an AOL message  Send mortioli a Yahoo! Message
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.
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 16 February 2005 :  07:12:17  Show Profile
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.”
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.2 seconds. Powered By: Snitz Forums 2000 Version 3.4.07