ASP Mail sending to multiple email addreses

I'm sending an email newsletter out using asp and am struggling to get it to send to multiple people from a list of people that i have stored in a microsoft access database.

I also would like it so that when it sends the receiver cannot see who else the email has been sent to.

I've attached the code that im currently trying to use (i know its wrong) - how can i get that Do loop to work properly? and how can i make it so that the receiver can only see their own email address?
SQLString = "SELECT email FROM email"
    rs.Open SQLString, DatabaseConnection
    if NOT rs.EOF then
    MyMail.AddAddress = "myemail@email.co.uk
    
    Do
    ", rs("email")"
    rs.MoveNext
    Loop until rs.EOF
    end if

Open in new window

jd1991Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Rajesh DalmiaConnect With a Mentor Commented:
as i said...

1. you have to send single email each person
2. put all email address in BCC
0
 
Rajesh DalmiaCommented:
in place of comma (,) it will be semi colon (;)
0
 
Rajesh DalmiaCommented:
if u dont want other to see then....

1. you have to send individual email to each person, member name in to address
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Rajesh DalmiaCommented:
another alternate way (not sure though if that's correct)

you can put all address in BCC field in place of To field... in To you can put ur own
BCC does not shows up in list... but in that case the person who is receiving won't be able to view his own address also in to field.
0
 
jd1991Author Commented:
i'll do it with semi-colons - thanks :)

any idea what's wrong with my Do loop?

i get the error below
Microsoft VBScript compilation  error '800a0409'

Unterminated string constant

/domain/domain/domain-process.asp, line 295

MyMail.AddAddress = "myemail@email.co.uk
-----------------------------------------^

Open in new window

0
 
Rajesh DalmiaCommented:
try this....

Do
     EmailList = EmailList & ";" & rs("email")
    rs.MoveNext
Loop until rs.EOF

MyMail.AddAddress = "myemail@email.co.uk" & EmailList
0
 
jd1991Author Commented:
get an error when i do, know what's wrong?

SQLString = "SELECT email FROM email"
    rs.Open SQLString, DatabaseConnection
    if NOT rs.EOF then
    Do
     EmailList = EmailList & ";" & rs("email")
    rs.MoveNext
    Loop until rs.EOF
   
    MyMail.AddAddress = "myemail@email.co.uk" & EmailList
    end if
    rs.Close
ADODB.Recordset error '800a0e7d'

The connection cannot be used to perform this operation. It is either closed or invalid in this context.

/domain/domain/domain-process.asp, line 293

Open in new window

0
 
Rajesh DalmiaCommented:
what's there in line 293....
r u doing any other data retrieve etc outside the loop....
0
 
jd1991Author Commented:
ok sorted that, i accidently removed the wrong line so it wasn't accessing the database correctly!

now have a different error though:

"Microsoft VBScript runtime  error '800a01b6'

Object doesn't support this property or method: 'AddAddress'

/brendataylor/backoffice/backoffice-process.asp, line 303 "

line 303 is:

MyMail.AddAddress = "myemail@email.co.uk" & EmailList
0
 
Rajesh DalmiaCommented:
which component u r using for mail fire... can u post the mail fire code....
in above code try

MyMail.AddAddress "myemail@email.co.uk" & EmailList

0
 
Rajesh DalmiaCommented:
in asp u should use CDO for mail fire... more details u can get at

http://www.asp101.com/articles/john/cdosmtprelay/default.asp
0
 
jd1991Author Commented:
ok fixed that error i think, now have a different one though lol

here's the second part of the email sending (the first part has the body and set's MyMail

OpenDBConn
    SQLString = "SELECT email FROM email"
    rs.Open SQLString, DatabaseConnection
    MyMail.IsHTML = True
    MyMail.From = "info@domain.co.uk"
    MyMail.Username = "info@domain.co.uk"
    MyMail.Password = "testing"
   
    if NOT rs.EOF then
    Do
     EmailList = EmailList & ";" & rs("email")
    rs.MoveNext
    Loop until rs.EOF
    MyMail.AddAddress "info@email.co.uk" & EmailList
    end if
    MyMail.Subject = "New Email Newsletter Subscriber"

      If MyMail.Send Then
        Response.Redirect("domain-selectMail.asp")
    Else
        Response.Redirect("domain.asp")
    End If
    rs.Close
    CloseDBConn


the error is below, line 306 is "If MyMail.Send Then"
Persits.MailSender.4 error '800a0006'

501 5.1.3 Bad recipient address syntax

/domain/domain/domain-process.asp, line 306 

Open in new window

0
 
Rajesh DalmiaCommented:
the addresses coming from db... there you have invalid address I guess...
print EmailList on screen and check the values...
0
 
jd1991Author Commented:
just done that, they're real email addresses - i just changed the semi-colon's to commars and it works perfectly.

so it doesn't work when i use semi-colon's. The email is now sent out to anyone on the database list, but got the problem of them all being able to see who its sent to again - any other thoughts?
0
 
jd1991Author Commented:
ok will give that a go, thanks for your help - should be fine now
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.