This topic is locked

Email Read Receipt

10/23/2007 12:38:11 PM
ASPRunnerPro General questions
J
JOHNF777 author

I've got a couple of Events where I email data to multiple people.
Two Questions....

  1. Is it possible to change the "From:" to the Session("UserIDEmail") ?
  2. I'm wondering if it is possible to do a "Request Read Receipt" ? So we can track when the recipient has read the email?
    Thanks.
    /John

Sergey Kornilov admin 10/24/2007

You can do both if you use your own email sending routine.
Another choice - modify Sub Sendmail in include/commonfunctions.asp according to your needs.
For more info I recommend to check the following article:

http://www.paulsadowski.com/WSH/cdo.htm

J
JOHNF777 author 10/25/2007

Thanks, Sergey. I'll read more into that article.
I'm sure I'll find a solution for this.
Thanks.

J
JOHNF777 author 10/25/2007

Just wanted to share my findings.....
Here's what I added in the commonfunctions.asp
Look for:

'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



-----

After this line I added:

str = "select from dbo.My_Users where UserId='" & Session("UserID") &"'"

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

rsTemp.open str, dbConnection

cfrom=rsTemp("Email")

rsTemp.Close : set rsTemp = Nothing

*
Now, when the email is sent, the "From" is based on the logged in user's email address.
I'll read up some tonite if I can figure out the return receipt.
/JohnF

Sergey Kornilov admin 10/25/2007

John,
see the line you need to add to enable return receipt (in bold):

' SMTP username and passwords

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cнdo/configuration/sendpassword";) = csmtppassword

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cнdo/configuration/sendusername";) = csmtpuser

myMail.Configuration.Fields("urn:schemas:mailheader:return-receipt-to") = "me@my.com"

myMail.Configuration.Fields.Update

J
JOHNF777 author 10/31/2007

I finally got read receipt to work and here's the code I had change in the Sendmail function. I just wanted to share it to other users.
A couple of things I wanted to do.... I wanted the "From" email to use the user's emaill address which is stored in my Users table. 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

Sergey Kornilov admin 10/31/2007

Thank you for sharing your code.
You may want to post in "Tips and tricks" section and get all the credit.