# Email html

**URL:** <https://forum.kirupa.com/t/email-html/9868>\
**Category:** programming\
**Created:** [December 19, 2002, 11:32pm UTC](https://forum.kirupa.com/t/email-html/9868 "2002-12-19T23:32:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisbees1](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@chrisbees1](https://forum.kirupa.com/u/chrisbees1)\
**Post date:** [December 19, 2002, 11:32pm UTC](https://forum.kirupa.com/t/email-html/9868/1 "2002-12-19T23:32:37Z")

</div>

Hi, i want to be able to send an email which when its viewed it just acts as a .html page. However i want it to appear just where an email would without having to click an attachment or something like that. Obviously the email viewing site would have to support html.

I hope someone can help!

thanks in advance, chris

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 19, 2002, 11:50pm UTC](https://forum.kirupa.com/t/email-html/9868/2 "2002-12-19T23:50:59Z")

</div>

chris,  
it all depends on your email host. if they allow html in outgoing email, then you shouldn’t have a problem. if not, then your out of luck.

if they do, look for a place that they designated for html emails (not a lot have these) if you cant find one, just copy and paste your html code into the main body of the email, and make sure you link the images to actual urls, and not just href=“bla.jpg” because they wont get it.

well, ive never done it, so if im wrong do correct me.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 19, 2002, 11:54pm UTC](https://forum.kirupa.com/t/email-html/9868/3 "2002-12-19T23:54:30Z")

</div>

ok thanks ill give that a go and get back to you.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 27, 2002, 6:46am UTC](https://forum.kirupa.com/t/email-html/9868/4 "2002-12-27T06:46:07Z")

</div>

If your hosted on a nt or 2000 box chances are they have CDONTS available which is easily accessed with asp…try this code.

```php

<% Option Explicit
dim objEmail
Set objEmail = CreateObject("CDONTS.Newmail")

'have the user input a name in the form or email address then request it
objEmail.From = Request.Form("email address")

'return email address
objEmail.To = "you@you.com"

'subject line
objEmail.Subject = "subject line stuff"

'0=MIME 1=Text
objEmail.BodyFormat = "0"

'Set the format
objEMail.MailFormat = 0

'Put your HTML normal code here be sure t collect your form elements using the request object
objEMail.Body = "<h2>Hello</h2><br><b>This is my e-mail in HTML format<%= request.form=("formElement")</b>"

'send the mail
objEmail.Send

'alway close your stuff
Set objEmail = Nothing

'this is going to be your response that the email was sent.
Response.Write"<html><head><title>Confimation</title><body><center><table width=300 border=0 cellspacing=0 cellpadding=0 style=border-collapse: collapse; border-top: 1px solid black; border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; font-family: verdana, arial; font-size: 10px; color: #000033; background-color: #e9e9e9;><tr align=center><td colspan=3><table width=275 border=0 cellspacing=5 cellpadding=5><tr align=center><td colspan=3><font size=-1>Thank You Your message was sent:</font></td></tr><tr><td>&nbsp;</td><td align=center onClick=javascript:self.close();><font size=-1><strong>.:close this window:.</strong></font></td><td>&nbsp;</td></tr></table></td></tr></table></center></body></head></html>"
%>

```

[edit by lostinbeta to show code: also I advise to use the php VB code tags to show code as this board converts html]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 27, 2002, 6:46am UTC](https://forum.kirupa.com/t/email-html/9868/5 "2002-12-27T06:46:49Z")

</div>

Why is my code not showing???

\<% Option Explicit  
dim objEmail  
Set objEmail = CreateObject(“CDONTS.Newmail”)

'have the user input a name in the form or email address then request it  
objEmail.From = Request.Form(“email address”)

'return email address  
objEmail.To = "you@you.com"

'subject line  
objEmail.Subject = “subject line stuff”

'0=MIME 1=Text  
objEmail.BodyFormat = “0”

'Set the format  
objEMail.MailFormat = 0

'Put your HTML normal code here be sure t collect your form elements using the request object  
objEMail.Body = “\<h2\>Hello\</h2\>\<br\>\<b\>This is my e-mail in HTML format\<%= request.form=(“formElement”)\</b\>”

'send the mail  
objEmail.Send

'alway close your stuff  
Set objEmail = Nothing

'this is going to be your response that the email was sent.  
Response.Write"\<html\>\<head\>\<title\>Confimation\</title\>\<body\>\<center\>\<table width=300 border=0 cellspacing=0 cellpadding=0 style=border-collapse: collapse; border-top: 1px solid black; border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; font-family: verdana, arial; font-size: 10px; color: #000033; background-color: #e9e9e9;\>\<tr align=center\>\<td colspan=3\>\<table width=275 border=0 cellspacing=5 cellpadding=5\>\<tr align=center\>\<td colspan=3\>\<font size=-1\>Thank You Your message was sent:\</font\>\</td\>\</tr\>\<tr\>\<td\>&nbsp;\</td\>\<td align=center onClick=javascript:self.close();\>\<font size=-1\>\<strong\>.:close this window:.\</strong\>\</font\>\</td\>\<td\>&nbsp;\</td\>\</tr\>\</table\>\</td\>\</tr\>\</table\>\</center\>\</body\>\</head\>\</html\>"  
%\>

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 27, 2002, 7:16am UTC](https://forum.kirupa.com/t/email-html/9868/6 "2002-12-27T07:16:10Z")

</div>

thanks lost…never posted code b4. I thought this was predominantly php place so I never answered here but it seems a few use ASP

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 30, 2002, 9:19pm UTC](https://forum.kirupa.com/t/email-html/9868/7 "2002-12-30T21:19:51Z")

</div>

I’m glad you asked.  
Heres the equivalent in PHP… 😃

```php

<?php
ob_start("mail");
if ( $_POST['submit'] ) 
{
$reciever = $_POST['reciever'];
$header = $_POST['header'];
$text= $_POST['text'];
mail($reciever,$header,$text);
header($_SERVER['PHP_SELF']);
ob_end_flush("mail");
ob_end_clean("mail");
}
print("<form action='".$_SERVER['PHP_SELF']."' method='post'");
print("reciever:<input type='text' name='reciever'>");
print("header:<input type='text' name='header'>");
print("text:<textarea width=20 height=40 type='text' name='text'></textarea>");
ob_end_flush("mail");
ob_end_clean("mail";

```
