Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send e-mail to multiple contacts in List box?

Status
Not open for further replies.

may1hem

Programmer
Jul 28, 2002
262
GB
I have a form which displays our company's clients and notes about them.

I want to be able to select some of my colleagues from a list box and send the client's notes to my colleauges.

I have created 2 tables: one for client details and notes, and the other table to hold my colleagues' names and e-mail addresses.

I created a form based on the clients table. Then I added a list box using the wizard, and asked it to look up values from the colleagues table. The list box shows only my colleagues' names. I have set the list box to allow multiple selections, using the Extended option.

How can I refer to the multiple selections through code?

Also, how can I refer to the e-mail addresses that correspond to the names selected in the list box? This is so that I can add the e-mail addresses to the e-mail recipients list.

Any ideas?

By the way, I am using Access 97.

Thanks,

May
 
I have solved this now.

Credit to qzl53x for the ideas!

Here's the code, if anyone needs it. By the way, I have 2 list boxes on the form, one for sending TO (called lstSendTo) and one for sending CC (called lstSendCc).
-----------------

With objOutlookMsg
' Add the To recipient(s) to the message.
Dim varTo As Variant
For Each varTo In Me![lstSendTo].ItemsSelected
Set objOutlookRecip = .Recipients.Add(Me![lstSendTo].ItemData(varTo))
objOutlookRecip.Type = olTo
Next varTo

' Add the CC recipient(s) to the message.
Dim varCc As Variant
For Each varCc In Me![lstSendCc].ItemsSelected
Set objOutlookRecip = .Recipients.Add(Me![lstSendCc].ItemData(varCc))
objOutlookRecip.Type = olCC
Next varCc
End With

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top