Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Need help in using Looping


Message #1 by "Joe Lee" <bugmania76@y...> on Tue, 3 Sep 2002 10:45:37
Hi everyone, i am trying to distribute a newsletter with a lists of 
customer email records from my database. I wanted to acheieve the list of 
emails from the record, like

mail.To = "a.abc1.com","b.abc2.com","c.abc1.com"

and this is my loop:

Dim i
    i=0
While NOT rsCust.EOF
	i=i+1 
mail.To= rsCust("cust_email") & ","
rsCust.MoveNext
Wend

This will produce continueous line of

mail.To="a.abc1.com",mail.To="b.abc.com"

Which i do not want.

Is there any way, i can solve this problem?

Thanks people,

Regards,
Joe
Message #2 by Sam Clohesy <sam@e...> on Tue, 3 Sep 2002 10:43:19 +0100
You could do:

Set objrsrs
)

	objRs.open strSql, objConn, 1
	intCount2 = 0

	Do While not objRs.EOF
		strBCC = strBCC
		strBCC = strBCC & objRs(0) & ";"
		intCount = intCount + 1
		intCount2 = intCount2 + 1
		If intCount > 100 Then
		'this is for sending in batches of 100-you may not want to
do this
			Set objMail = CreateObject("CDONTS.NewMail")
			objMail.From = "my address"
			objMail.Bcc = strBCC
			objMail.To = "your address"

Hope this is useful

Thanks

Sam




-----Original Message-----
From: Joe Lee [mailto:bugmania76@y...]
Sent: 03 September 2002 11:46
To: ASP Databases
Subject: [asp_databases] Need help in using Looping


Hi everyone, i am trying to distribute a newsletter with a lists of 
customer email records from my database. I wanted to acheieve the list of 
emails from the record, like

mail.To = "a.abc1.com","b.abc2.com","c.abc1.com"

and this is my loop:

Dim i
    i=0
While NOT rsCust.EOF
	i=i+1 
mail.To= rsCust("cust_email") & ","
rsCust.MoveNext
Wend

This will produce continueous line of

mail.To="a.abc1.com",mail.To="b.abc.com"

Which i do not want.

Is there any way, i can solve this problem?

Thanks people,

Regards,
Joe
Message #3 by "Samir Chitkara , Gurgaon" <chitkaras@g...> on Tue, 3 Sep 2002 15:18:39 +0530
dim strMail 

i=0

While NOT rsCust.EOF
	i=i+1 
	strMail=strMail & Trim(rsCust("cust_email")) & ","
	rsCust.MoveNext
Wend

Mail.To=strMail





-----Original Message-----
From: Joe Lee [mailto:bugmania76@y...]
Sent: Tuesday, September 03, 2002 4:16 PM
To: ASP Databases
Subject: [asp_databases] Need help in using Looping


Hi everyone, i am trying to distribute a newsletter with a lists of 
customer email records from my database. I wanted to acheieve the list of 
emails from the record, like

mail.To = "a.abc1.com","b.abc2.com","c.abc1.com"

and this is my loop:

Dim i
    i=0
While NOT rsCust.EOF
	i=i+1 
mail.To= rsCust("cust_email") & ","
rsCust.MoveNext
Wend

This will produce continueous line of

mail.To="a.abc1.com",mail.To="b.abc.com"

Which i do not want.

Is there any way, i can solve this problem?

Thanks people,

Regards,
Joe
Message #4 by "Joe Lee" <bugmania76@y...> on Tue, 3 Sep 2002 13:07:44
Thanks everyone for the fast and nice reponse.
However, i still have problem getting rid of the last ',' from the end of 
the list. Based on what Nick Stilwell had mentioned, i try to use this

While NOT rsCust.EOF
	i=i+1 
	strMail=strMail & Trim(rsCust("cust_email")) & ", "
	rsCust.MoveNext
Wend
strMail = Left(strMail,(Len(strMail)-1))
Response.Write(strMail)
mail.To = strMail

However, it still could not remove the last comma ',' at the end of the 
line..

Regards,
Joe
Message #5 by "Craig Flannigan" <ckf@k...> on Tue, 3 Sep 2002 13:03:45 +0100
You could just do:

strMail = Left(strMail, Len(strMail) -1)

This would remove the last ,



Craig.


-----Original Message-----
From: Joe Lee [mailto:bugmania76@y...]
Sent: 03 September 2002 13:08
To: ASP Databases
Subject: [asp_databases] RE: Need help in using Looping


Thanks everyone for the fast and nice reponse.
However, i still have problem getting rid of the last ',' from the end of
the list. Based on what Nick Stilwell had mentioned, i try to use this

While NOT rsCust.EOF
	i=i+1
	strMail=strMail & Trim(rsCust("cust_email")) & ", "
	rsCust.MoveNext
Wend
strMail = Left(strMail,(Len(strMail)-1))
Response.Write(strMail)
mail.To = strMail

However, it still could not remove the last comma ',' at the end of the
line..

Regards,
Joe

_____________________________________________________________________
Please contact I.T. Support if you have received this email in error.
This e-mail has been scanned for all viruses by Star Internet.
_____________________________________________________________________


_____________________________________________________________________
Kingfield Heath Ltd. Email Disclaimer

Confidentiality : This email and its attachments are intended for the
above-named only and may be confidential. If they have come to you in
error you must take no action based on them, nor must you copy or
show them to anyone; please reply to this email and highlight the
error.

Security Warning : Please note that this email has been created in
the knowledge that the internet is not a 100% secure communications
medium. We advise that you understand and observe this lack of
security when emailing us.

Viruses : Although we have taken steps to ensure that this email and
attachments are free from any virus, we advise that, in keeping with
good computing practice, the recipient should ensure they are
actually virus free.
_____________________________________________________________________
Message #6 by "Samir Chitkara , Gurgaon" <chitkaras@g...> on Tue, 3 Sep 2002 17:41:37 +0530
put this as the last line :

strMail = mid(strMail,1,len(strMail)-2)

-----Original Message-----
From: Joe Lee [mailto:bugmania76@y...]
Sent: Tuesday, September 03, 2002 6:38 PM
To: ASP Databases
Subject: [asp_databases] RE: Need help in using Looping


Thanks everyone for the fast and nice reponse.
However, i still have problem getting rid of the last ',' from the end of 
the list. Based on what Nick Stilwell had mentioned, i try to use this

While NOT rsCust.EOF
	i=i+1 
	strMail=strMail & Trim(rsCust("cust_email")) & ", "
	rsCust.MoveNext
Wend
strMail = Left(strMail,(Len(strMail)-1))
Response.Write(strMail)
mail.To = strMail

However, it still could not remove the last comma ',' at the end of the 
line..

Regards,
Joe
Message #7 by "Paulo Fernandes" <paulofernandes@c...> on Tue, 3 Sep 2002 13:13:22 +0100
Hi,

Use:

strMail =3D Left(strMail, Len(strMail)-2)

which will determine the length of the string and remove 2 characters
(the blank space and the comma).

HTH

PauloF

-----Original Message-----
From: Joe Lee [mailto:bugmania76@y...]
Sent: ter=E7a-feira, 3 de Setembro de 2002 13:08
To: ASP Databases
Subject: [asp_databases] RE: Need help in using Looping

Thanks everyone for the fast and nice reponse.
However, i still have problem getting rid of the last ',' from the end
of
the list. Based on what Nick Stilwell had mentioned, i try to use this

While NOT rsCust.EOF
	i=3Di+1
	strMail=3DstrMail & Trim(rsCust("cust_email")) & ", "
	rsCust.MoveNext
Wend
strMail =3D Left(strMail,(Len(strMail)-1))
Response.Write(strMail)
mail.To =3D strMail

However, it still could not remove the last comma ',' at the end of the
line..

Regards,
Joe

Message #8 by "Joe Lee" <bugmania76@y...> on Tue, 3 Sep 2002 13:24:50
Thanks!. 
actually the problem lies with the space and comma at the back
so actually i should use

strMail = Left(strMail, Len(strMail) -2)

to trim away the space after the comma too.

Thanks guys, you all are a great help to me

  Return to Index