Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending HTML email(s) with ASP using the code below 2

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
[tt]

Can someone please guide me as to how, using this email page code below, I can modify it to send an HTML email...


*********************** text email *************************

<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<html>
<body>
<%
dim mystring
mystring = &quot;%>
%>
<!--#include file=&quot;Connections/myDSN.asp&quot; -->
<%
Dim rsProposalEmail__MMColParam
rsProposalEmail__MMColParam = &quot;1&quot;
if (Session(&quot;NewID&quot;) <> &quot;&quot;) then rsProposalEmail__MMColParam = Session(&quot;NewID&quot;)
%>
<%
set rsProposalEmail = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsProposalEmail.ActiveConnection = MM_myDSN_STRING
rsProposalEmail.Source = &quot;SELECT * FROM dbo.TABLE WHERE request_id = &quot; + Replace(rsProposalEmail__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;&quot;
rsProposalEmail.CursorType = 0
rsProposalEmail.CursorLocation = 2
rsProposalEmail.LockType = 3
rsProposalEmail.Open()
rsProposalEmail_numRows = 0
%>
<%
'***********************************************************
Dim objMsg, strFrom, strTo, strSubject, strBody, lngImportance
strFrom = request.cookies(&quot;user&quot;)(&quot;email&quot;)
strTo = &quot;email1@myISP.com&quot; & &quot;;&quot; & &quot;email2@myISP.com&quot;
strSubject = request.cookies(&quot;user&quot;)(&quot;first&quot;) & &quot; &quot; & request.cookies(&quot;user&quot;)(&quot;last&quot;) & &quot; has submitted a Project Proposal&quot;
strBody = &quot;Proposal Description: &quot; & rsProposalEmail(&quot;Request_description&quot;)
strFile = &quot;bar.bmp&quot;
'***********************************************************

Set objMsg = Server.CreateObject(&quot;CDONTS.NewMail&quot;)

objMsg.From = strFrom
objMsg.To = strTo
objMsg.Subject = strSubject
objMsg.Body = strBody

objMsg.Send

Set objMsg = Nothing
%>
<%
rsProposalEmail.Close()
%>
<a name=&quot;ovhref&quot; href=&quot;<%=mystring%>&quot;></a>
<script language=&quot;JavaScript&quot;>
ovhref.click()
</script>
*********************** text email *************************

I would like the email to be 100% in HTML format including images. I'm stuck...

Thanks in advance.





[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

banana.gif
rockband.gif
banana.gif
 
Just add the following lines should do it

objMsg.MailFormat = cdoMailFormatMime
objMsg.BodyFormat = cdoBodyFormatHTML
 
Thanks for your response,
How about if I wanted to add an image banner to the top of the email. Where would I code that? Thanks

[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

banana.gif
rockband.gif
banana.gif
 
Route the link for the banner image to where its stored on your server. Will work fine if they are still connected to the internet, which they probably will be if they're downloading email, hmm does that make sense lol
 
hmmmm, I don't understand. What do you mean by route?

You know, as I type here, I'm thinking that what if I wanted to display an html table in my email with colored cells what would I do it?

I guess I should've asked how to send a 100% email message including tables and images. Would you know how to do this?

[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

banana.gif
rockband.gif
banana.gif
 
Thanks for the help GaryC123. The HTML email with the banner is working perfect. I now have to figure out how to format my email body with tables. Thanks again.


[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

banana.gif
rockband.gif
banana.gif
 
Heres a working version with a table put some colors in it just for you :eek:)

<%Set objMsg = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
objMsg.MailFormat = cdoMailFormatMime
objMsg.BodyFormat = cdoBodyFormatHTML
objMsg.From = &quot;&quot;
objMsg.To = &quot;&quot;

objMsg.Subject = &quot;&quot;
htmlbody=&quot;<table border=&quot;&quot;1&quot;&quot; cellspacing=&quot;&quot;1&quot;&quot; width=&quot;&quot;100%&quot;&quot;>&quot;
htmlbody=htmlbody & &quot;<tr><td width=&quot;&quot;33%&quot;&quot;>&nbsp;</td><td width=&quot;&quot;33%&quot;&quot;>&nbsp;</td>&quot;
htmlbody=htmlbody & &quot;<td width=&quot;&quot;34%&quot;&quot;>&nbsp;</td></tr><tr>&quot;
htmlbody=htmlbody & &quot;<td width=&quot;&quot;33%&quot;&quot; bgcolor=&quot;&quot;#00FF00&quot;&quot;>&nbsp;</td>&quot;
htmlbody=htmlbody & &quot;<td width=&quot;&quot;33%&quot;&quot;>&nbsp;</td><td width=&quot;&quot;34%&quot;&quot;>&nbsp;</td>&quot;
htmlbody=htmlbody & &quot;</tr><tr><td width=&quot;&quot;33%&quot;&quot;>&nbsp;</td>&quot;
htmlbody=htmlbody & &quot;<td width=&quot;&quot;33%&quot;&quot;>&nbsp;</td>&quot;
htmlbody=htmlbody & &quot;<td width=&quot;&quot;34%&quot;&quot; bgcolor=&quot;&quot;#000080&quot;&quot;>&nbsp;</td>&quot;
htmlbody=htmlbody & &quot;</tr></table>&quot;
objMsg.Body =htmlbody
objMsg.Send

Set objMsg = Nothing %>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top