Link to home
Start Free TrialLog in
Avatar of jd1991
jd1991Flag for United Kingdom of Great Britain and Northern Ireland

asked on

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

Avatar of Rajesh Dalmia
Rajesh Dalmia
Flag of India image

in place of comma (,) it will be semi colon (;)
if u dont want other to see then....

1. you have to send individual email to each person, member name in to address
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.
Avatar of jd1991

ASKER

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

try this....

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

MyMail.AddAddress = "myemail@email.co.uk" & EmailList
Avatar of jd1991

ASKER

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

what's there in line 293....
r u doing any other data retrieve etc outside the loop....
Avatar of jd1991

ASKER

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
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

in asp u should use CDO for mail fire... more details u can get at

http://www.asp101.com/articles/john/cdosmtprelay/default.asp
Avatar of jd1991

ASKER

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

the addresses coming from db... there you have invalid address I guess...
print EmailList on screen and check the values...
Avatar of jd1991

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Rajesh Dalmia
Rajesh Dalmia
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jd1991

ASKER

ok will give that a go, thanks for your help - should be fine now