Hi, I've written some VB to automate the sending of reports from a DB using GroupWise. The actual class module that creates the mail is over 1000 lines which I got off the net somwhere and managed to intergrate into my Db. It is then called and defined in another module. It worked fine for a while but a problem with the array that contains the recipients has appeared. I've never worked with arrays before and have a pretty limited knowledge of them.
In the class module is:
Private mastrRecTo() As String
'mastrRecTo(0, i)=address; mastrRecTo(1, i)=display name
In the modlue that calls the class is
Dim strRecTo(1, 0) As String
If I add addresses like this:
strRecTo(0, 0) = "tknight@hillingdon.gov.uk"
strRecTo(1, 0) = "tknighttest@hillingdon.gov.uk"
it works fine. The thing is that I need the reports go to different amounts of people (from 1 to 7 addresses). For this reason I decided to set up a loop to run through a recipient recordset and add each recipient one at a time.
While Not ToRecRst.EOF
strRecTo(n, 0) = ToRecRst.[E-Mail]
n = n + 1
ToRecRst.MoveNext
Wend
This also works but in order to accommodate the maximum number of recipients I need to set the array to 7. When the amount of recipients is less than 7 I get an error and the e-mails won't be sent. I tried defining the array with a variable for each set of reports:
Dim strRecTo(n, 0) As String
but i get an error message saying that the array value has to be constant. Can anyone help me get round the problem? Thanks, Tom.
In the class module is:
Private mastrRecTo() As String
'mastrRecTo(0, i)=address; mastrRecTo(1, i)=display name
In the modlue that calls the class is
Dim strRecTo(1, 0) As String
If I add addresses like this:
strRecTo(0, 0) = "tknight@hillingdon.gov.uk"
strRecTo(1, 0) = "tknighttest@hillingdon.gov.uk"
it works fine. The thing is that I need the reports go to different amounts of people (from 1 to 7 addresses). For this reason I decided to set up a loop to run through a recipient recordset and add each recipient one at a time.
While Not ToRecRst.EOF
strRecTo(n, 0) = ToRecRst.[E-Mail]
n = n + 1
ToRecRst.MoveNext
Wend
This also works but in order to accommodate the maximum number of recipients I need to set the array to 7. When the amount of recipients is less than 7 I get an error and the e-mails won't be sent. I tried defining the array with a variable for each set of reports:
Dim strRecTo(n, 0) As String
but i get an error message saying that the array value has to be constant. Can anyone help me get round the problem? Thanks, Tom.