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!

Send HTML formatted email from an uploaded HTML file

Status
Not open for further replies.

Taco

Programmer
Apr 1, 2001
32
US
I have an asp page that is used to send out distribution lists. It consists of a MessageBox, a file upload box and some check boxes that are used for email only, fax only or HTML email. When you check off HTML email the code takes the HTML file you upload and writes that HTML to the body of the email. It works great for Outlook and some other email clients but not for AOL or web-based email accounts - they receive all of the HTML <TAGS> as the email message and no images. The code looks like this:

If HTMLChk = &quot;on&quot; then
Mailer.ContentType = &quot;text/html&quot;
If oUpl.IsEmpty = False Then
NewFileName = Mid(oUpl.UserFilename, InstrRev(oUpl.UserFilename, &quot;\&quot;) + 1)
oUpl.SaveAs NewFileName
FileName2 = oUpl.ServerName
SendMessage = &quot;&quot;
Dim fObj, f
Set fObj = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
if fObj.FileExists (FileName2) then
Set f = fObj.OpenTextFile(FileName2,1,FALSE,FALSE)
Do until f.AtEndOfStream = True
SendMessage = SendMessage & f.ReadLine & vbCrLf
Loop
end if
Set fOBj = nothing
End If

Any suggestions would greatly be appreciated. Marketing likes to send out the pretty emails. Thanks.
 
Hi,

I'm giving a suggestion... try to send a pure txt file with the same content of HTML as an attachement.

Regards,
Luís Silva
 
Taco,

You could try using CDO to send the email. I have sent HTML emails using CDO and they appear fine in web based mail systems ( Hotmail and Ireland.com). This is a sample of some of my code:

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

' This code assumes the above CDO instantiation code is included
objCDO.To = me@mywebaddress.com
objCDO.From = &quot;pwadmin@myconpany.ie (Password Reminder)&quot;
objCDO.bcc = &quot;me@mycompany.com&quot;

objCDO.Mailformat=0 ' Specifies HTML Message Format
objCDO.Bodyformat=0 ' Specifies HTML Message Format

Dim MailBody

MailBody = &quot;<!DOCTYPE HTML PUBLIC &quot;&quot;-//W3C//DTD W3 HTML//EN&quot;&quot;>&quot;
MailBody = MailBody & &quot;<HTML>&quot; & vbcrlf
MailBody = MailBody & &quot;<HEAD><TITLE>Client Area Password Reminder</TITLE></HEAD>&quot;
MailBody = MailBody & &quot;<BODY>&quot; & vbcrlf
MailBody = MailBody & &quot;Dear &quot; & record.Fields(&quot;UserName&quot;) & &quot;,<BR><BR>&quot;
MailBody = MailBody & &quot;Your login details for the client area are as follows:<BR><BR>&quot;
MailBody = MailBody & vbcrlf
MailBody = MailBody & &quot;<TABLE BORDER=&quot;&quot;0&quot;&quot; CELLSPACING=&quot;&quot;2&quot;&quot;>&quot;
MailBody = MailBody & &quot;<TR><TD><B>User ID:</B></TD><TD>&quot; & record.Fields(&quot;UserID&quot;) & &quot;</TD></TR>&quot;
MailBody = MailBody & &quot;<TR><TD><B>Password:</B></TD><TD>&quot; & record.Fields(&quot;Password&quot;) & &quot;</TD></TR>&quot;
MailBody = MailBody & &quot;</TABLE>Do not reply to this mail.</BODY></HTML>&quot;

objCDO.Subject = &quot;Client Interactive Area Login Details.&quot;
objCDO.Body = MailBody
objCDO.Send


Hope this is of some help. Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top