PDA

View Full Version : html email from multipart form


Boxhead
01-06-2004, 05:29 PM
I have a form users can fill in like an outlook message. Users can also add attachments which are added to the server without using COM so the form has to use enctype multipart/form-data.

This form is processed, the attachment added to the server using objUpload, an HTML email built, the attachment added, the email sent then the attachemtn deleted of the server. (I have not done both the attachment and the deletion of the attachment yet).

the trouble is that the email wont send in html form. I have tested it changing the enctype and it works with the standard enctype.

Any idea of what I am doing wrong or if this is possible - here is the email I get:

Date: Tue, 6 Jan 2004 10:36:01 -0000
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----=_NextPart_000_0016_01C3D440.E1165B00"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165

This is a multi-part message in MIME format.

------=_NextPart_000_0016_01C3D440.E1165B00
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

=09
=09
=09
me and you ,

this is the body oh jrts ehg fdhtfd hfg fgs hg=20

this is the close=20
from me=20


Email Address: this is my email <mailto:this is my email=00 >=20



------=_NextPart_000_0016_01C3D440.E1165B00
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC"-//IETF//DTD HTML//EN"><html><head><title></title><st=
yle type=3D"text/css"><!--body {background-color:#FFFFCC; font-family: Aria=
l, Helvetica, sans-serif; font-size: 10pt; margin:0px 0px 0px 0px; }table.s=
ide {background-repeat: repeat-y}--></style></head><body><table width=3D"10=
0%" border=3D"0" cellpadding=3D"0" cellspacing=3D"0"><tr><td width=3D"75"><=
img src=3D"http://www.mysite.uk/assets/template/top.gif" width=3D"76=
" height=3D"2" alt=3D"" /></td><td width=3D"55" rowspan=3D"2"><img src=3D"h=
ttp://www.mysite.uk/assets/template/top_left.gif" width=3D"55" heigh=
t=3D"31" alt=3D"" /></td><td width=3D"100%" rowspan=3D"2" background=3D"htt=
p://www.mysite.uk/assets/template/top_bar.gif" class=3D"repx"> =
</td><td width=3D"3" rowspan=3D"3"><img src=3D"http://www.mysite.uk/=
assets/template/top_end.gif" width=3D"3" height=3D"89" alt=3D"" /></td><td =
width=3D"10"><img src=3D"http://www.mysite.uk/assets/spacer.gif" wid=
th=3D"1" height=3D"2" alt=3D"" /></td></tr><tr><td rowspan=3D"2"><img src=
=3D"http://www.mysite.uk/assets/template/badge.jpg" width=3D"76" hei=
ght=3D"87" alt=3D"" /></td><td><img src=3D"http://www.mysite.uk/asse=
ts/spacer.gif" width=3D"1" height=3D"29" alt=3D"" /></td></tr><tr><td><img =
src=3D"http://www.mysite.uk/assets/template/email_temp_06.gif" name=
=3D"Image1" width=3D"55" height=3D"58" border=3D"0" id=3D"Image1" /></td><t=
d align=3D"center"><img src=3D"http://www.mysite.uk/assets/template/=
email_title.gif" width=3D"553" height=3D"58" alt=3D"" /></td><td><img src=
=3D"http://www.mysite.uk/assets/spacer.gif" width=3D"1" height=3D"58=
" alt=3D"" /></td></tr></table><table class=3D"side" width=3D"96%" height=
=3D"100%" border=3D"0" cellspacing=3D"0" cellpadding=3D"0"><tr><td width=3D=
"2%" background=3D"http://www.mysite.uk/assets/template/email_temp_0=
8.gif"><img src=3D"http://www.mysite.uk/assets/spacer.gif" width=3D"=
55" height=3D"100" /></td><td width=3D"98%" valign=3D"top">me and you
,<p>this is the body
</p>this is the close
<br />from me
<br /><p style=3D"font-size:10pt">Email Address: <a href=3D"mailto:this is =
my email
">this is my email
</a></p></td></tr></table>
</body></html>
------=_NextPart_000_0016_01C3D440.E1165B00--

glenngv
01-07-2004, 03:46 AM
http://www.codingforums.com/showthread.php?s=&threadid=31076#post160835

Boxhead
01-07-2004, 10:29 AM
Glenn

Sorry forgot to reply to your post on my original thread!

The problems that were highlighted in your suggested thread are not my problem (i have Mail.MailFormat = 0 Mail.BodyFormat = 0) and with some trial and error I found that my html email works fine when the enctype is changed.

i thought i would start a new thread from my original because the problem was a different one from the original post subject.

Any ideas on what could be causing the problem? (I can post code if not)

monkey

glenngv
01-07-2004, 11:23 AM
Can you post some code then?

Boxhead
01-07-2004, 12:15 PM
Here is the code that process the form (enctype=multiform) and sends the email. at the moment the attachment is uploaded but not added to the email (one step at a time!!) The include files are the same as on the site mentioned on my original post.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#INCLUDE FILE="clsUpload.asp"-->
<%
Dim Upload
Dim FileName1
Dim Folder

Set Upload = New clsUpload


' Grab the file names
FileName1 = Upload.Fields("file1").FileName

' Get path to save file to
Folder = Server.MapPath("..\temp_attach") & "\"

' Save the binary data to the file system
Upload("file1").SaveAs Folder & FileName1

'Get other values from form
from = Upload.Fields("from").Value
yemail = Upload.Fields("your_email").Value
whoto = Upload.Fields("whoto").Value
temail = Upload.Fields("their_email").Value
cc = Upload.Fields("cc").Value
bcc = Upload.Fields("bcc").Value
'attach = Upload.Fields("attach").Value
subject = Upload.Fields("subject").Value
body = Upload.Fields("body").Value
compclose = Upload.Fields("close").Value

' Release upload object from memory
Set Upload=nothing
%>
<%
'------------------------------------------
'Construct email, add attachment and send
Dim objMail, bodyTxt

Set objMail = Server.CreateObject("CDONTS.NewMail")

objMail.From = "webserver@mysite.com"
objMail.Subject = subject
objMail.To = temail
objMail.Cc = cc
objMail.Bcc = bcc
bodyTxt = bodyTxt & "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
bodyTxt = bodyTxt & "<html><head><title></title>"
bodyTxt = bodyTxt & "<style type=""text/css"">"
bodyTxt = bodyTxt & "<!--"
bodyTxt = bodyTxt & "body {background-color:#FFFFCC; font-family: Arial, Helvetica, sans-serif; font-size: 10pt; margin:0px 0px 0px 0px; }"
bodyTxt = bodyTxt & "table.side {background-repeat: repeat-y}"
bodyTxt = bodyTxt & "-->"
bodyTxt = bodyTxt & "</style>"
bodyTxt = bodyTxt & "</head><body>"
bodyTxt = bodyTxt & "<table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0""><tr>"
bodyTxt = bodyTxt & "<td width=""75""><img src=""http://www.mysite.com/assets/template/top.gif"" width=""76"" height=""2"" alt="""" /></td>"
bodyTxt = bodyTxt & "<td width=""55"" rowspan=""2""><img src=""http://www.mysite.com/assets/template/top_left.gif"" width=""55"" height=""31"" alt="""" /></td>"
bodyTxt = bodyTxt & "<td width=""100%"" rowspan=""2"" background=""http://www.mysite.com/assets/template/top_bar.gif"" class=""repx"">&nbsp;</td>"
bodyTxt = bodyTxt & "<td width=""3"" rowspan=""3""><img src=""http://www.mysite.com/assets/template/top_end.gif"" width=""3"" height=""89"" alt="""" /></td>"
bodyTxt = bodyTxt & "<td width=""10""><img src=""http://www.mysite.com/assets/spacer.gif"" width=""1"" height=""2"" alt="""" /></td></tr>"
bodyTxt = bodyTxt & "<tr><td rowspan=""2""><img src=""http://www.mysite.com/assets/template/badge.jpg"" width=""76"" height=""87"" alt="""" /></td>"
bodyTxt = bodyTxt & "<td><img src=""http://www.mysite.com/assets/spacer.gif"" width=""1"" height=""29"" alt="""" /></td></tr>"
bodyTxt = bodyTxt & "<tr><td><img src=""http://www.mysite.com/assets/template/email_temp_06.gif"" name=""Image1"" width=""55"" height=""58"" border=""0"" id=""Image1"" /></td>"
bodyTxt = bodyTxt & "<td align=""center""><img src=""http://www.mysite.com/assets/template/email_title.gif"" width=""553"" height=""58"" alt="""" /></td>"
bodyTxt = bodyTxt & "<td><img src=""http://www.mysite.com/assets/spacer.gif"" width=""1"" height=""58"" alt="""" /></td></tr></table>"
bodyTxt = bodyTxt & "<table class=""side"" width=""96%"" height=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0""><tr>"
bodyTxt = bodyTxt & "<td width=""2%"" background=""http://www.mysite.com/assets/template/email_temp_08.gif""><img src=""http://www.mysite.com/assets/spacer.gif"" width=""55"" height=""100"" /></td>"
bodyTxt = bodyTxt & "<td width=""98%"" valign=""top"">"
bodyTxt = bodyTxt & whoto & ",<p>"& body & "</p>" & compclose & "<br />" & from & "<br /><p style=""font-size:10pt"">Email Address: <a href=""mailto:"&yemail&""">" & yemail
bodyTxt = bodyTxt & "</a></p></td></tr></table>"

objMail.BodyFormat=0
objMail.MailFormat=0
objMail.Body = bodyTxt
'objMail.AddAttachment attach
objMail.Send
'------------------------------------------
set objMail = nothing
'Now redirect the web user back to a thanks page
Response.Redirect("../message.asp?m=email")
%>