This topic is locked

Email Option on Export Page

1/8/2007 11:57:16 AM
ASPRunnerPro General questions
B
bankman author

I have been trying to figure out how to send an email containing all records. I have managed to send just a test email but I am stuck when trying to send an emial containg all the records. Can anyone point me in the right direction?

D
dlangham 1/8/2007

You could try something like this below and modify it for your use.
[codebox]//These below are the 2 form fields used

strnam = Trim(Request.Form("E-Mail"))

strname = Trim(Request.Form("Name"))
Set Conn = Server.CreateObject("ADODB.Connection")

sConnect = "Provider=YOUR CONNECTION STRING")
Conn.Open sConnect

Set rsEmails=Conn.Execute("SELECT * FROM TABLE")
if (strnam <> "")then

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "YOUR MAIL SUBJECT"

StrBody ="<font color=red><b>[ THIS IS AN AUTOMATED E-MAIL, PLEASE DO NOT REPLY ]</b></font>"
Do While not rsEmails.eof

strBody= strBody & rsEmails("FIELD1") & " " & " <strong>'"& rsEmails ("FIELD2") &"'</strong>" & ", "&rsEmails ("FIELD3")& " " & " <font color=red><strong>"& rsEmails ("FIELD4") &"</strong></font>"& "
" & "
"

rsEmails.movenext

loop
objMessage.From = "YOUR MAIL ADDRESS"

objMessage.To = strnam

objMessage.HtmlBody = strBody & "
" & "THANK YOU 1." & "
" & "
" & "Kind Regards" & "
" & "YOUR NAME" & "
" & "
"

objMessage.Configuration.Fields.Item

("http://schemas.microsoft.com/cdo/configuration/sendusing";) = 2

objMessage.Configuration.Fields.Item


("http://schemas.microsoft.com/cdo/configuration/smtpserver";) = "YOUR MAIL SERVER"

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpserverport";) = 25

objMessage.Configuration.Fields.Update

objMessage.Send

set rsEmails = nothing

Conn.close

Set Conn = nothing

end if[/codebox]
I hope it helps you out...sorry if there are any mistakes in it!!!