This topic is locked

Email Read Receipt

10/31/2007 4:47:05 PM
ASPRunnerPro Tips and tricks
J
JOHNF777 author

Here's how to get read receipt (and delivery receipt) to work
Here's the code I had change in the Sendmail function that is located in the commonfunctions.asp.
A couple of things I wanted to do in my program....

  1. I wanted the "From" email to use the user's emaill address which is stored in my Users table.
  2. I wanted to do the return receipt only in certain instances/applications.
    Code may need improvement but it works. Btw, if you want this to work on IIS 5.0 (Win2000) just change the If statement of the IIS to <= 4.0
    --------------

    Sub sendmail(email, subject, message)
    Dim i

    if email="" or isnull(email) then

    strMessage = "Email address is empty. Cannot send email."

    Exit Sub

    end if
    'On Error Resume Next
    Version = Request.ServerVariables("SERVER_SOFTWARE")

    If InStr(Version, "Microsoft-IIS") > 0 Then

    i = InStr(Version, "/")

    If i > 0 Then

    IISVer = Trim(Mid(Version, i+1))

    End If

    End If
    '----- Added by JohnF - change the FROM email field to use the user's email address.

    str = "select * from Users where UserId='" & Session("UserID") &"'"

    Set rsTemp = server.CreateObject("ADODB.Recordset")

    rsTemp.open str, dbConnection

    cfrom=rsTemp("Email")

    rsTemp.Close : set rsTemp = Nothing

    '----- Added by John end
    ' changed from 5.0 to let CDO work in IIS 5.0

    If IISVer <= "3.0" Then

    ' Windows NT / 2000 without CDO

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

    myMail.From = cfrom

    myMail.To = email
    myMail.Subject = subject

    myMail.Body = message

    myMail.Send

    Set myMail = Nothing

    Else

    ' Windows XP / 2003

    Set myMail=CreateObject("CDO.Message")

    myMail.Subject = subject

    myMail.From=cfrom

    myMail.To=email

    myMail.TextBody= message
    'added by JohnF below --- return receipt email only to the group below.

    If email="email1@mycompany.com" then

    mymail.fields("urn:schemas:mailheader:disposition-notification-to") = cfrom

    myMail.Fields("urn:schemas:mailheader:return-receipt-to")=cfrom

    End If

    If email="email2@mycompany.com" then

    mymail.fields("urn:schemas:mailheader:disposition-notification-to") = cfrom

    myMail.Fields("urn:schemas:mailheader:return-receipt-to")=cfrom

    End If

    mymail.DSNOptions = cdoDSNNever

    mymail.DSNOptions = 1

    mymail.Fields.update

P
peer33 10/3/2008

Normally mail to send one person to another, A received person must study and reply the mail.
-------------------------------

peer
Sreevysh Corp

J
JOHNF777 author 10/31/2008

Normally mail to send one person to another, A received person must study and reply the mail.

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

peer
Sreevysh Corp


Not sure what you mean by this.....