|  | Concatenate Email Addresses |  | |
| | | SoDakRah |  |
| Posted: Wed Sep 03, 2008 7:59 pm Post subject: Concatenate Email Addresses |  |
I want to read a table of users and concatenate their email addresses into one long string to address one email instead of individual emails.
Example table A has 10 employees, 2 departments D1, D2
I use a query to open a recordset RST and read through the table extracting each email for a selected department. strTo = RST.email Now I want to append the next users email address to the first one. Something like strTo = strTo & "," & RST.email
This does not work.
Any help will be appreciated. |
| |
| | | pietlinden@hotmail.com |  |
| Posted: Wed Sep 03, 2008 10:15 pm Post subject: Re: Concatenate Email Addresses |  |
On Sep 3, 4:59 pm, SoDakRah <SoDak...@discussions.microsoft.com> wrote:
| Quote: | I want to read a table of users and concatenate their email addresses into one long string to address one email instead of individual emails.
Example table A has 10 employees, 2 departments D1, D2
I use a query to open a recordset RST and read through the table extracting each email for a selected department. strTo = RST.email Now I want to append the next users email address to the first one. Something like strTo = strTo & "," & RST.email
This does not work.
Any help will be appreciated.
|
It doesn't work because you're not looping anywhere...
dim rs as dao.recordset set rs=CurrentDB.Querydefs("YourQueryDef").OpenRecordset do until rs.EOF strTo = strTo & "," &rs.Fields("EMail") rs.MoveNext Loop strTo=right$(strTo,len(strTo)-1) |
| |
| | | SoDakRah |  |
| Posted: Thu Sep 04, 2008 2:36 pm Post subject: Re: Concatenate Email Addresses |  |
| |  | |
Sorry, I did have a do...loop in the code but did not include that information. I was getting an error (Object Required) on the strTo=strTo line and thought it has something to do with setting a string equal to itself. Your message made me look very close at my code and I found a mispelled field name. Is my face red! I corrected that and the loop works perfectly. Thanks for your assistance.
"pietlinden@hotmail.com" wrote:
| Quote: | On Sep 3, 4:59 pm, SoDakRah <SoDak...@discussions.microsoft.com wrote: I want to read a table of users and concatenate their email addresses into one long string to address one email instead of individual emails.
Example table A has 10 employees, 2 departments D1, D2
I use a query to open a recordset RST and read through the table extracting each email for a selected department. strTo = RST.email Now I want to append the next users email address to the first one. Something like strTo = strTo & "," & RST.email
This does not work.
Any help will be appreciated.
It doesn't work because you're not looping anywhere...
dim rs as dao.recordset set rs=CurrentDB.Querydefs("YourQueryDef").OpenRecordset do until rs.EOF strTo = strTo & "," &rs.Fields("EMail") rs.MoveNext Loop strTo=right$(strTo,len(strTo)-1)
|
|
| |
|
|