I am bouncing on the upper limit up with sending emails to smtp server at
about 300, I do not whant to increase amount of email messages on server
config.

I have a vbscript that pulls emails address's from an sqldb as a
concatinated string ie.
fred@address.com;jack@address.com;bill@address.com;dan@address.com etc..

I need to break up thatstring into blocks of 100 so that i can send multiple
emails instead of 500+ address in BCC field

Anyone have an idea whats the best way to do it.

Don

Re: Help with string breakup by Michael

Michael
Fri May 21 21:41:41 CDT 2004

Don Grover wrote:
> I am bouncing on the upper limit up with sending emails to smtp
> server at about 300, I do not whant to increase amount of email
> messages on server config.
>
> I have a vbscript that pulls emails address's from an sqldb as a
> concatinated string ie.
> fred@address.com;jack@address.com;bill@address.com;dan@address.com
> etc..
>
> I need to break up thatstring into blocks of 100 so that i can send
> multiple emails instead of 500+ address in BCC field
>
> Anyone have an idea whats the best way to do it.


Best is a subject term ;-)...

Here's a *simple* way...

strOfEmailAddresses = _
"fred@address.com;jack@address.com;bill@address.com;dan@address.com"

arrayOfAddresses = split(strOfEmailAddresses, ";")

Now you can walk the arrayOfAddresses and build smaller concateneted
strings...


--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US


Re: Help with string breakup by Don

Don
Fri May 21 21:57:29 CDT 2004

"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:u13fRZ6PEHA.1392@TK2MSFTNGP09.phx.gbl...
> Don Grover wrote:
> > I am bouncing on the upper limit up with sending emails to smtp
> > server at about 300, I do not whant to increase amount of email
> > messages on server config.
> >
> > I have a vbscript that pulls emails address's from an sqldb as a
> > concatinated string ie.
> > fred@address.com;jack@address.com;bill@address.com;dan@address.com
> > etc..
> >
> > I need to break up thatstring into blocks of 100 so that i can send
> > multiple emails instead of 500+ address in BCC field
> >
> > Anyone have an idea whats the best way to do it.
>
>
> Best is a subject term ;-)...
>
> Here's a *simple* way...
>
> strOfEmailAddresses = _
> "fred@address.com;jack@address.com;bill@address.com;dan@address.com"
>
> arrayOfAddresses = split(strOfEmailAddresses, ";")
>
> Now you can walk the arrayOfAddresses and build smaller concateneted
> strings...
>

This is what i came up with, and tests ok !

Dim iCounter,sAddress
'Load uup test string
For iCounter = 1 to 0
sAddress = sAddress & ";" & iCounter & "@me.com"
Next
'--------------------------

Dim arrAddress, lngMaxAddress, sNewAddress
arrAddress = Split(sAddress, ";", -1, 1)
lngMaxAddress = UBound(arrAddress)
If lngMaxAddress > 1 Then
For iCounter = 1 To lngMaxAddress
If Int(iCounter / 100) = (iCounter / 100) Then
WScript.Echo Left(sNewAddress, Len(sNewAddress) - 1)
sNewAddress = ""
End If
sNewAddress = sNewAddress & arrAddress(iCounter) & ";"
Next
WScript.Echo Left(sNewAddress, Len(sNewAddress) - 1)
End If



Re: Help with string breakup by anonymous

anonymous
Sat May 22 03:46:02 CDT 2004

Hi u could have simply called the split function like this.
Split(sAddress, ";", 100, 1)
The 100 in this method will return u only the first 100 values in the array.

Re: Help with string breakup by Don

Don
Sat May 22 05:32:56 CDT 2004

How would this break of 600+ into 100 lots ?

"cssrk" <anonymous@discussions.microsoft.com> wrote in message
news:32C71C94-B63A-42E4-A98E-CC52656DC5FE@microsoft.com...
> Hi u could have simply called the split function like this.
> Split(sAddress, ";", 100, 1)
> The 100 in this method will return u only the first 100 values in the
array.



Re: Help with string breakup by Michael

Michael
Sat May 22 14:20:46 CDT 2004

> How would this break of 600+ into 100 lots ?

By itself that one-liner doesn't, but the technique could be used...

Here's an example. I'm not suggesting that you change what you already have
since it does what you want. In fact, the code you have is probably easier
to read/understand than the example I'm giving you. I've sprinkled it some
fairly gratuitous comments to make how the process works clearer.

'=====
'arData is just to build a strAddresses value for the example...
'=====
redim arData(250)
for x = 0 to 250
arData(x) = "user" & x & "@somewhere.com"
next
strAddresses = join(arData,";")

'=====
'arAddresses is a dynamic array used to collect the 100 (max)
'address subsets present in strAddresses...
'=====
dim arAddresses()
idxAddress = -1

'=====
'split is used to parse strAddresses into an array with a
'maximun number of elements one greater than we want. If
'we get the max number of elements, then the last one is the
'unparsed remainder. Parsing continues until there is no
'unparsed remainder...
'=====
lenRemainder = len(strAddresses)
do until lenRemainder = 0
'=====
'note: the max number of elements argument of split is 1 based...
'=====
arWork = split(strAddresses,";",101)
'=====
'note: the ubound of an array is a 0 based index...
'=====
if ubound(arWork) = 100 then
'we got the max - save the last element as the data
'to split on the last pass abd remove it from arWork...
strAddresses = arWork(100)
redim preserve arWork(99)
else
'=====
'no unparsed remander to save...
'=====
strAddresses = ""
end if
'=====
'join the work array back into a semicolon delimited string and
'save it as the next element in the dynamic arAddresses array...
'=====
idxAddress = idxAddress + 1
redim preserve arAddresses(idxAddress)
arAddresses(idxAddress) = join(arWork,";")
lenRemainder = len(strAddresses)
loop

'=====
'show that we have an array of the address subsets we wanted...
'=====
for each strAddressSet in arAddresses
wscript.echo strAddressSet
next


--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US


Re: Help with string breakup by Michael

Michael
Sat May 22 15:41:40 CDT 2004


: "cssrk" <anonymous@discussions.microsoft.com> wrote in message
: news:32C71C94-B63A-42E4-A98E-CC52656DC5FE@microsoft.com...
: > Hi u could have simply called the split function like this.
: > Split(sAddress, ";", 100, 1)
: > The 100 in this method will return u only the first 100 values in the
: array.
:

"Don Grover" <spamfree@assoft.com.au> wrote in message news:#Oxxng#PEHA.1160@TK2MSFTNGP09.phx.gbl...
: How would this break of 600+ into 100 lots ?
:

one of the ways

str = "don@work;ray@home;joe@club;bob@shop;fred@neighbours;tom@city;dick@brothel;"

do while instr(str,";") > 0
str = replace(replace(str,";","~",1,2),";","|",1,1) 'for testing this - making lines of 3
'str = replace(replace(str,";","~",1,99),";","|",1,1) 'actual line
loop

str = replace(str,"~",";")
lines = split(str,"|")
msgbox join(lines,vbnewline)



Re: Help with string breakup by Michael

Michael
Sat May 22 16:05:09 CDT 2004

...snip...

> lenRemainder = len(strAddresses)
> do until lenRemainder = 0
> '=====
> 'note: the max number of elements argument of split is 1 based...
> '=====
> arWork = split(strAddresses,";",101)
> '=====
> 'note: the ubound of an array is a 0 based index...
> '=====
> if ubound(arWork) = 100 then
> 'we got the max - save the last element as the data
> 'to split on the last pass abd remove it from arWork...

that comment line should say...

'to split on the next pass and remove it from arWork...

> strAddresses = arWork(100)
> redim preserve arWork(99)
> else
> '=====
> 'no unparsed remander to save...
> '=====
> strAddresses = ""
> end if

...snip...

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US