Sending emails in Outlook, emails in Access table

J

jacobe2008

I have the following table in Access

Email Field1
[email protected] message1
[email protected] message2
[email protected] message3

I would like to send one email to [email protected] that lists everything in
Field1.

Sample email:
Dear person1, please look at message1, message2, message3

Currently I have a VBA code that sends 3 emails to [email protected]. The
first email has message1, the second email has message 2, and the third email
has message 3.

My VBA code looks like the following (in pseudo code):

While Not end of table
Make an email message
myItem.HTMLBody = Field1
myItem.Display
myItem.Send
rst.MoveNext
Wend

Any idea how I can modify this code to send just one email to person1@email.
com?
 
C

Carl Rapson

jacobe2008 said:
I have the following table in Access

Email Field1
[email protected] message1
[email protected] message2
[email protected] message3

I would like to send one email to [email protected] that lists everything
in
Field1.

Sample email:
Dear person1, please look at message1, message2, message3

Currently I have a VBA code that sends 3 emails to [email protected]. The
first email has message1, the second email has message 2, and the third
email
has message 3.

My VBA code looks like the following (in pseudo code):

While Not end of table
Make an email message
myItem.HTMLBody = Field1
myItem.Display
myItem.Send
rst.MoveNext
Wend

Any idea how I can modify this code to send just one email to
person1@email.
com?

How about something like this:

While Not end of table
Make an email message
myItem.HTMLBody = myItem.HTMLBody & Field1
rst.MoveNext
Wend
myItem.Display
myItem.Send


You'll need to modify the porocedure somewhat to include commas and such so
that your Body text comes out how you want, but you should be able to get
the gist of it.

Carl Rapson
 
J

jacobe2008 via AccessMonster.com

Thanks for the response Carl. Actually, I have more than one person in the
table, and I think this is what makes things a little complicated, to send
one email per person.

Email Field1
[email protected] message1
[email protected] message2
[email protected] message3
[email protected] message4
[email protected] message5
[email protected] message6
[email protected] message7
[email protected] message8
[email protected] message9

Carl said:
I have the following table in Access
[quoted text clipped - 28 lines]
person1@email.
com?

How about something like this:

While Not end of table
Make an email message
myItem.HTMLBody = myItem.HTMLBody & Field1
rst.MoveNext
Wend
myItem.Display
myItem.Send

You'll need to modify the porocedure somewhat to include commas and such so
that your Body text comes out how you want, but you should be able to get
the gist of it.

Carl Rapson
 
C

Carl Rapson

You'll need a way of segregating your recordset by user. One way I've done
this is to have 2 loops, first looping through distinct persons and then all
messages for that person. Something like:

rst1 = "SELECT DISTINCT Email FROM table"
DO WHILE NOT rst1.EOF
rst2 = "SELECT Field1 FROM table WHERE Email = '" & rst1.Email & "'"
DO WHILE NOT rst2.EOF
myItem.HTMLBody = myItem.HTMLBody & rst2.Field1
rst2.MoveNext
LOOP
myItem.Display
myItem.Send
rst1.MoveNExt
LOOP

Carl Rapson

jacobe2008 via AccessMonster.com said:
Thanks for the response Carl. Actually, I have more than one person in
the
table, and I think this is what makes things a little complicated, to send
one email per person.

Email Field1
[email protected] message1
[email protected] message2
[email protected] message3
[email protected] message4
[email protected] message5
[email protected] message6
[email protected] message7
[email protected] message8
[email protected] message9

Carl said:
I have the following table in Access
[quoted text clipped - 28 lines]
person1@email.
com?

How about something like this:

While Not end of table
Make an email message
myItem.HTMLBody = myItem.HTMLBody & Field1
rst.MoveNext
Wend
myItem.Display
myItem.Send

You'll need to modify the porocedure somewhat to include commas and such
so
that your Body text comes out how you want, but you should be able to get
the gist of it.

Carl Rapson
 
Top