Solved

ASP Mail sending to multiple email addreses

Posted on 2010-08-30
15
947 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In this article we will discuss some EI Capitan Mail app issues and provide some manual process to resolve them.
Email attacks are the most efficient and effective way for cyber criminals and hackers to compromise a computer or network. We often find our-self second guessing the authenticity of an email message, for such instances we can follow practical princ…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
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: …

758 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

20 Experts available now in Live!

Get 1:1 Help Now