473,414 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

How to grab multiple email addresses using listbox?

Hi all,

I created a listbox with employees' names and email addresses in it, and a button which grabs email address once it's clicked. Currently I can only pick up one address at a time, but I also want to be able to grab multiple addresses. My code is as follows:

Private Sub SendCommand_Click()

Dim strName As String
Dim strEmail As String


strName = Me.List45.Column(0)
strEmail = Me.List45.Column(1)

DoCmd.SendObject acSendNoObject, "None", acFormatHTML, strEmail

End Sub

This can only pick up one email address when I look up the listbox and click the button. Can anyone show me how to grab multiple addresses?

Thanks a bunch,

zg
Aug 23 '07 #1
3 4403
JConsulting
603 Expert 512MB
Hi all,

I created a listbox with employees' names and email addresses in it, and a button which grabs email address once it's clicked. Currently I can only pick up one address at a time, but I also want to be able to grab multiple addresses. My code is as follows:

Private Sub SendCommand_Click()

Dim strName As String
Dim strEmail As String


strName = Me.List45.Column(0)
strEmail = Me.List45.Column(1)

DoCmd.SendObject acSendNoObject, "None", acFormatHTML, strEmail

End Sub

This can only pick up one email address when I look up the listbox and click the button. Can anyone show me how to grab multiple addresses?

Thanks a bunch,

zg

This bit should get you pointed in the right direction
Expand|Select|Wrap|Line Numbers
  1. For Each x In List0.ItemsSelected
  2. If strAddress = "" Then
  3.    strAddress = List0.ItemData(x)
  4. Else
  5.     strAddress = strAddress & "; " & List0.ItemData(x)
  6. End If
  7. Next x
  8. If Nz(strAddress, "") = "" Then
  9. MsgBox "You must select an e-mail recipient"
  10. Exit Sub
  11. End If
  12.  
Aug 24 '07 #2
This can be easily done throuugh following code

Private Sub testmultiselect_Click()
Dim oItem As Variant
Dim sTemp As String
Dim iCount As Integer

iCount = 0

If Me!Nameslist.ItemsSelected.Count <> 0 Then
For Each oItem In Me!Nameslist.ItemsSelected
If iCount = 0 Then
sTemp = sTemp & Me!Nameslist.ItemData(oItem)
iCount = iCount + 1
Else
sTemp = sTemp & ";" & Me!Nameslist.ItemData(oItem)
iCount = iCount + 1
End If
Next oItem
Else
MsgBox "Nothing was selected from the list", vbInformation
Exit Sub 'Nothing was selected
End If

Me!mySelections.Value = sTemp
End Sub
Private Sub clrList_Click()
Call clearListBox
Me!mySelections.Value = Null
End Sub

However, you have to create following fields & commands button also as follows:
List Box
----------------------------------------------------
Name : NamesList
Row Source Type : Table/Query
Row Source : SELECT Email FROM Employees
Multi Select : Extended
Width : 3.5"
Height : 0.75"


Text Box
-----------------------
Name : mySelections
Width : 3.5"
Height : 0.25"

Command Button
----------------------------------
Name : testmultiselect
Caption : Display Selected Items
Width : 1.375"
Height : 0.3"

Command Button
----------------------
Name : ClrList
Caption : Clear List
Width : 1.375"
Height : 0.3"
Aug 24 '07 #3
to select multiple address I use a sub form in datasheet view with a bolean field where the bolean is true you use those addresses with that and the code left above you should be able to do what you want unless I completely misunderstood the ?
Aug 24 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jonathan Levy | last post by:
We have SQL Server 2000 Standard and recently moved from Exchange 5.5 to Exchange 2003. This problem occurred both before and after the e-mail change. We would like to send notifications of...
2
by: (Pete Cresswell) | last post by:
For better or worse, I have chosen to implement mailing addresses in a particular application as a separate table. One Person ==> Many Addresses. It is a database for managing school reunions...
2
by: Jen | last post by:
Trying to take one table in access and split it into multiple excel files(using an excel template); and then email based on email addresses in Table2; Of course, I would like to do all of this...
2
by: .Net Newbie | last post by:
Hello, I am currently coding my ASP.Net pages in c# and have run into a question concerning Emails. I have four objects on a page (six including 2 buttons). The first is a subject line...
4
by: Michelle | last post by:
Hi Is it possible/anyone know how to send a document (.pdf) to multiple recipients using POP where the email is not just a matter of throwing 1000 email addresses in the BCC list, but each email...
3
by: Bernard Lebel | last post by:
Hello, Is there an option or a way to allow the selection of multiple entries in the Listbox widget? I could not find any, and would like to allow the end user to select multiple entries. ...
6
by: fstenoughsnoopy | last post by:
I have a customer order database and I need to pull a customers information, ie first name, last name, address, city, state, zip, phone, etc, into the oder table. i don't know how to go about...
1
by: Marisa | last post by:
Hi. I am new to C#, and I am having trouble getting the multiple selection of listbox to work. I have an asp.net web form, and I need two listboxes which are filled with an access table. I have...
12
by: micarl | last post by:
How would i print a report based on criteria selected from several Combo Boxes as well as multiple Multi Select List Boxes, that are located on the same form? I can get one Multi List Box, just...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.