Using Persits mailsender need to AddBcc to an email address from a database

'Create Email
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "smtp host"
Mail.Username = "username"
Mail.Password = "password"
Mail.AddBcc  this is where I need it to pull one address out of DB based on unique ID from recordset
Mail.From = "noreply@domain.com"
Mail.FromName = "FromName"
Mail.Subject = "Subject"
Mail.Body = EmailContent

Mail.IsHTML = True
Mail.Send
LVL 12
netsmithcentralAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Om PrakashCommented:
You can connect to DB and get the same

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"

set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT bcc_field FROM Customers where condition = 'test'", conn
Dim bccField
if not rs.EOF then
   bccField = rs("bcc_field")   
end if
rs.close
conn.close

'Add BCC here
Mail.AddBcc  = bccField 
%>

Open in new window

0
netsmithcentralAuthor Commented:
thanks om_prakash_p
but I get the following:

Microsoft VBScript runtime  error '800a01b6'

Object doesn't support this property or method: 'Mail.AddBcc'
0
netsmithcentralAuthor Commented:
Due to the need to grab only one Email address based on the ID associated with the form data being submitted,  the form submit page needs to redirect to an asp page with the following code:


<%
Dim rsBCCs__MMColParam
rsBCCs__MMColParam = "1"
If (Request.QueryString("ID") <> "") Then
  rsBCCs__MMColParam = Request.QueryString("ID")
End If
%>
<%
Dim rsBCCs
Dim rsBCCs_cmd
Dim rsBCCs_numRows
Set rsBCCs_cmd = Server.CreateObject ("ADODB.Command")
rsBCCs_cmd.ActiveConnection = MM_BACKEND_STRING
rsBCCs_cmd.CommandText = "SELECT * FROM tblFORMWHERE ID = ?"
rsBCCs_cmd.Prepared = true
rsBCCs_cmd.Parameters.Append rsBCCs_cmd.CreateParameter("param1", 5, 1, -1, rsBCCs__MMColParam) ' adDouble
Set rsBCCs = rsBCCs_cmd.Execute
rsBCCs_numRows = 0
%>
<%

 'Email HTML
EmailContent = "<body bgcolor='#FFFFFF'>" _
& "<div align='left'>&nbsp;</div>" _
& "<p>Email messagep>" _
& "<p>More email message and link<a href='http://www.domain.com./page.asp' target='_blank'> here.</a></p></body>"



'Create Email and Add BCC Here
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "serverIP"
Mail.Username = "username"
Mail.Password = "password"
Mail.AddBcc "admin@domain.com"
Mail.AddBcc rsBCCs("Email")
Mail.From = "noreply@domain.com"
Mail.FromName = "No Reply"
Mail.Subject = "New Email"
Mail.Body = EmailContent

Mail.IsHTML = True
Mail.Send

%>
<%
rsBCCs.Close()
Set rsBCCs = Nothing
%>
<% Response.Redirect("thankyou.asp")%>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.