Print Page | Close Window

HTML Emails

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10090
Printed Date: 29 March 2026 at 4:41am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: HTML Emails
Posted By: Misty
Subject: HTML Emails
Date Posted: 21 April 2004 at 6:24pm
I would like to send html emails to people from a form on a web page. I would like to be able to tell when someone reads the email. I would like for the email to redirect to a web page like http://www.anywhere.com/reademail.asp?ID=4 - http://www.anywhere.com/reademail.asp?ID=4 . But I don't want the email to actually take the person to the web page. Can someone please give me a few lines of code on how to do this?



Replies:
Posted By: dpyers
Date Posted: 21 April 2004 at 8:08pm

http://www.aspfaq.com/show.asp?id=2474 - http://www.aspfaq.com/show.asp?id=2474

Bear in mind that the trend in email clients is to have html display turned off by default.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: thekiwi
Date Posted: 26 April 2004 at 5:04pm
Originally posted by dpyers dpyers wrote:

http://www.aspfaq.com/show.asp?id=2474 - http://www.aspfaq.com/show.asp?id=2474

Bear in mind that the trend in email clients is to have html display turned off by default.


Which isnt a problem if you send both headers, ie PlainText and HTML
eg

            Set objMailer = Server.CreateObject("CDOnts.NewMail")
            objMailer.BodyFormat = CdoBodyFormatHTML
            objMailer.MailFormat = CdoMailFormatText



-------------
Cheers
TheKiwi
http://www.infobahn.co.nz - Internet Infobahn - website design and hosting


Posted By: Misty
Date Posted: 27 April 2004 at 3:05pm

thekiwi,

Do you know if I will still be able to track when someone reads my email if they open the email in Plain Text?



Posted By: dpyers
Date Posted: 27 April 2004 at 5:44pm

With either an HTML or a text email, you can have an active link to take a user to a page.

With HTML, you can include an image in the email that is loaded from your site. You can set up the image src for something like http://www.mysite.com/image.jpg?ID&NUM=9999 - http://www.mysite.com/image.jpg?ID&NUM=9999 - where 9999 is some code that you put on that specific email.

You then write yourself a little script to view your logs and pull the 999's and match them up against your data base to find out who opened the email. - Note that instead of 9999, you could have something like IDNUM=Username

I use Outlook 2003 which has images turned off by default so this wouldn't work for me or for similar email clients.

You can also send either a text or an html email with a "Request Receipt" option. But most email clients will not send you a receiept by default.

Bottom line is that there's no sure way to tell if someone reads your email.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Misty
Date Posted: 27 April 2004 at 9:46pm

I have created the web pages. However, I have one problem. I get notified by email that the person has read the email after I have sent it which is not true. How do I fix this problem?

Here are some significiant lines of code to look at:

MHTMLBody = "http://www.--------.com/ReadEmail.asp?ID=" & EmailNum

Few lines of code for ReadEmail.asp:

If Read = false then rs("TimeRead") = Now()
'Set value of boolean field
rs("Read") = true rs.Update

 



Posted By: dpyers
Date Posted: 28 April 2004 at 1:27am

Originally posted by Misty Misty wrote:

I have created the web pages. However, I have one problem. I get notified by email that the person has read the email after I have sent it which is not true.

Do you get notified for all emails you send, or just some of them?

You'll have to print more code. what you show may mean something to someone else, but it puzzles me.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Misty
Date Posted: 28 April 2004 at 1:43am

I get notified for all of the emails that I send out. I will give you the code for both web pages (1. The web page that sends the email out. 2.) The ASP page that adds yes to the read box in the database when someone has read a particular email.

The page that sends the email:

<%

'EmailSent.asp

%>

<%

    'declare variables

    'Strings for recipient, subject, boby

    Dim SubjectLine, Body, EmailNum

    Dim MyMail 'The Jmail object

    Dim rs

 

    'grab the variables from the form

    EmailNum = Request.QueryString("EmailID")

  

   

    'Declare constants for a recordset that allows adding records

     

   

      dim sqlString

      dim connectionString, databaseName, path

      dim SEmail, Sender, EmailBody, Email

      dim Name, Msg, EmailAddr

     

     

      

      'Set connection details

     

  

      sqlString = "Select * FROM Emails, Users"

      'Add WHERE Join clause

      sqlString = sqlString & " where Emails.EmailID=Users.EmailID"

      sqlString = sqlString & " and Emails.EmailID=" & EmailNum

      set rs = Server.CreateObject("ADODB.Recordset")

      rs.Open sqlString, connectionString

    

  

    'loop through the recordset

    While Not rs.EOF

    SEmail = rs("SEmail")

    Sender = rs("Sender")

    Name = rs("Name")



Posted By: Misty
Date Posted: 29 April 2004 at 2:38pm
Can someone please help me with this?


Posted By: dpyers
Date Posted: 29 April 2004 at 10:39pm
Did You try explicitly setting the Read field to False when the email is sent out?

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Misty
Date Posted: 29 April 2004 at 10:43pm
No, I didn't. Let me see if it'll work.


Posted By: Misty
Date Posted: 29 April 2004 at 10:53pm

It didn't work for the ASP page that sends out the email. 

I think that the MHTMLBody code is causing the problem because it refers to ReadEmail.asp.

This is the code in my reademail.asp page:

If Read = false then
rs("TimeRead") = Now()

'Set value of boolean field
rs("Read") = true rs.Update

I tried setting the read to false in reademail.asp, but it didn't work. I don't know what's wrong.

 



Posted By: dpyers
Date Posted: 30 April 2004 at 10:48am
Misty,
Check your PM.

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Misty
Date Posted: 02 May 2004 at 9:39pm

I really appreciate Don's help. I finally got the application working. However, there is one small problem I'd like to solve.

I included a logo in the html emails that I send out. I want this logo to show up clearly in the html emails that I send out.

Please look at this line of code: EmailBody = EmailBody & vbCrLf & vbCrLf & "<p><img src=""http://www.anywhere.com" & "/reademail.asp?ID=" & EmailNum & """>"

The name of the image file on reademail.asp is logo.gif. It's on the reademail.asp page. How do I get the logo to show up clearly instead of a broken image?



Posted By: dpyers
Date Posted: 02 May 2004 at 10:06pm
In your email clients, view the source of the email that is sent out. Is the broken image referenced as logo.gif or as  http://www,anywhere..com/logo.gif

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Misty
Date Posted: 02 May 2004 at 10:18pm

I looked at the view source. It is referenced as <img src=" http://www.anywhere.com/reademail.asp?ID=9 - http://www.anywhere.com/reademail.asp?ID=9 "> I've chosen to type anywhere instead of the real web site address for security reason.

I would like for the logo to show up. The logo is on the reademail.asp page.



Posted By: Misty
Date Posted: 04 May 2004 at 3:10pm

I really appreciate Don's help. I have solved all of my problems. I wanted to share the code for the ASP page that sends out the email and the ASP Page that notifies users when someone has read their emails. This is very useful if you want to send HTML emails to your friends and would like to find out if they have read your email. You will need to create a form page and a page that adds the information to a database. The lines of code that are in red are significant.

Code for the page that sends out the email:

<% 

Option Explicit

'=========================================================== =====

' name: EmailSent.asp

' programmer: Misty Roberts

'Procedures:

' DrawPage()

'=========================================================== =====

      'Declare constants for a recordset that allows adding records

      Const adLockOptimistic = 3

      Const adOpenDynamic = 2

      dim sqlString

      dim connectionString, databaseName, Path

      dim rs

     

      Dim SubjectLine, Body, EmailNum

      dim SEmail, Sender, EmailBody

      dim Name, Msg, EmailAddr, Email

  

    'grab the variables from the form

    EmailNum = Request.QueryString("EmailID")

     

     

     'Set connection details

     Add your database connection details here

  

      sqlString = "Select * FROM Emails, Users"

      'Add WHERE Join clause

      sqlString = sqlString & " where Emails.EmailID=Users.EmailID"

      sqlString = sqlString & " and Emails.EmailID=" & EmailNum

     

      set rs = Server.CreateObject("ADODB.Recordset")

      rs.Open sqlString, connectionString, adOpenDynamic, adLockOptimistic

     

 

  



Posted By: jb--
Date Posted: 27 January 2005 at 10:29am
Hi
 
Is it possible to send HTML emails using the code at ASP FAQ even though my server only supports Jmail?
 
Thanks
 
Jb


Posted By: Misty
Date Posted: 27 January 2005 at 1:18pm
What are you talking about? Please give me the exact URL for ASP FAQs. This is an old thread from last year. Did you want to be able to find out when people read your emails too?


Posted By: dj air
Date Posted: 27 January 2005 at 1:45pm
please do not drag up old threads.

if you want to rel;ate to a thread please mention and link to the thread.


Posted By: jb--
Date Posted: 27 January 2005 at 4:53pm
Sorry guys.  I'm just new to this forum.  What I am referring to is the first two messages in this topic.
 
Originally posted by dpyers dpyers wrote:

http://www.aspfaq.com/show.asp?id=2474 - http://www.aspfaq.com/show.asp?id=2474

Bear in mind that the trend in email clients is to have html display turned off by default.

 
All I would simply like to do is send html emails from a form on a web page.  I have tried using the code on the ASP FAQ website as advised above but have been unable to get it working.  My server only supports Jmail - would this be the reason?  If so is there any other code I can use?
 
Thanks
 
Jb


Posted By: dj air
Date Posted: 27 January 2005 at 5:17pm
if you use the Web wiz forum application look at the send_mail_function file..

ussually you need to set the body type to 1

1 ussually = html
0 = plain text.

also have a look at the mailing list for an example.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net