Solved

ASP Mail sending to multiple email addreses

Posted on 2010-08-30
15
948 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:jd1991
  • 9
  • 6
15 Comments
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 33557505
in place of comma (,) it will be semi colon (;)
0
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 33557511
if u dont want other to see then....

1. you have to send individual email to each person, member name in to address
0
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 33557520
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
 

Author Comment

by:jd1991
ID: 33557547
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
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 33557561
try this....

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

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

Author Comment

by:jd1991
ID: 33557615
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
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 33557655
what's there in line 293....
r u doing any other data retrieve etc outside the loop....
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:jd1991
ID: 33557781
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
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 33557848
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
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 33557860
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
 

Author Comment

by:jd1991
ID: 33558082
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
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 33558167
the addresses coming from db... there you have invalid address I guess...
print EmailList on screen and check the values...
0
 

Author Comment

by:jd1991
ID: 33558191
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
 
LVL 11

Accepted Solution

by:
Rajesh Dalmia earned 500 total points
ID: 33558243
as i said...

1. you have to send single email each person
2. put all email address in BCC
0
 

Author Comment

by:jd1991
ID: 33558285
ok will give that a go, thanks for your help - should be fine now
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you having trouble connecting or getting your iPhone / Samsung device(s) to sync with Microsoft Exchange Server?   What have you tried?   What haven't you tried?
Ransomware continues to be a growing problem for both personal and business users alike and Antivirus companies are still struggling to find a reliable way to protect you from this dangerous threat.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now