|
-
Aug 8th, 2000, 06:38 AM
#1
Thread Starter
Junior Member
I'm working on ASP aplication which send emails.
I want get email add from DB,but I need to put "," between each email add like
>objEMail.To = "email_add_1,email_add_2,..."
Then I have no idea how to put ",".
I'm writing a script like below.
><%
> dim Email(10)
> NoOfEmails = 0
> set conntemp=server.createobject("adodb.connection")
> DSN_Name = GetDSN("***")
> conntemp.open DSN_Name
> set rstemp=conntemp.execute("select email from email_table where dept='Sales'")
> do while not rstemp.eof
> NoOfEmail = NoOfEmail + 1
> Email(NoOfEmail) = rstemp(0)
>
> rstemp.movenext
> loop
> rstemp.close
> for x = 1 to NoOfEmail
> %>
> objEMail.To ="<%=Email(x)%>"
><%
> Next
Dose anyone know how to do this?
Please advice.
-
Aug 9th, 2000, 06:21 AM
#2
Code:
<%
dim Email(10)
NoOfEmails = 0
set conntemp=server.createobject("adodb.connection")
DSN_Name = GetDSN("***") ' BTW: What's this all about...your own function?
conntemp.open DSN_Name
set rstemp=conntemp.execute("select email from email_table where dept='Sales'") ' Strange way to do it...I'd use: rstemp.open "select email from email_table where dept='Sales'", conntemp
do while not rstemp.eof
NoOfEmail = NoOfEmail + 1
Email(NoOfEmail) = rstemp(0)
rstemp.movenext
loop
rstemp.close
for x = 1 to NoOfEmail
objEMail.To=Email(x) & ", "
Next
objEMail.To = left(objEMail.To, len(objEMail.To) - 2 ) ' Trim off the last ", "
%>
-
Aug 9th, 2000, 08:45 AM
#3
Thread Starter
Junior Member
Thanks!
Thanks very much!!
Sorry that my codes included my own function.
Thanks again.
-
Aug 9th, 2000, 10:34 AM
#4
-
Aug 10th, 2000, 02:27 AM
#5
Thread Starter
Junior Member
how to put values in order?
I'm having problem.
If I do like
<%
for x = 1 to NoOfEmail
objEMail.To=Mail_add
Mail_add=Email(x) & ", "
Next
response.write Mail_add
objEMail.To = left(Mail_add, len(Mail_add) - 2 )
%>
Then I get only first value, though I need get them like
Email(1),Email(2),Email(3),....Email(x), .
How do I put them that way?
Please help.
-
Aug 10th, 2000, 04:30 AM
#6
I'd have thought that woudl have worked. Erm...maybe the To property is write only...so every time you do something like
it's like writing
Get what I'm on about? Dunno if I've explained it very well.
Try building up the "to" line in a temporary variable first then put it into objEMail.To
-
Aug 10th, 2000, 04:59 AM
#7
Thread Starter
Junior Member
mmm...
I'm confused...
I think my last code was very confusing.
Now I write the code below, then I want "response.write Send_Dept" give me the line next.
" Email(1),Email(2),Email(3),....Email(x), . "
But it only gives me back the first value.
<%
for x = 1 to NoOfEmail
Send_Dept=E_mail(x) & ", "
Next
response.write Send_Dept
objEMail.To = left(Send_Dept, len(Send_Dept) - 2 )
%>
I feel like I'm not explaining well...
Wish you get what I mean.
Thanks
-
Aug 10th, 2000, 05:36 AM
#8
(Sigh). Erm...dunno...perhaps NoOfEmail has a value of 0 or 1 or something for some reason?
-
Aug 10th, 2000, 05:42 AM
#9
Thread Starter
Junior Member
Thanks anyway
Well,thanks anyway.
I appreciate your replies.
I guess what I need to know here is " How to put values in ' Value(1),Value(2),...Value(x)' style". So I think I will put new thread about this.
-
Aug 10th, 2000, 08:10 AM
#10
Thread Starter
Junior Member
My DB master taught me new way to solve my original question.
It DOES work. So FYI, I leave codes below.
Isn't it useful?
<%
set conntemp=server.createobject("adodb.connection")
conntemp.open DSN_Function
set rstemp=conntemp.execute("select email from email_table where dept='Sales'")
set objEMail = Server.CreateObject("CDONTS.NewMail")
EmailTxt = ""
do while not rstemp.eof
If not isnull(rstemp(0)) then
EmailTxt = EmailTxt & rstemp(0) & ", "
end if
rstemp.movenext
loop
rstemp.close
set rstemp = nothing
set conntemp = nothing
objEMail.To = left(EmailTxt, len(EmailTxt) - 2)
%>
>matthewralston
Using left function this way is very neat, I think.
-
Aug 10th, 2000, 05:16 PM
#11
Ah...so you found a REAL expert! 
Good on ya.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|