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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple E-Mail Addresses

Status
Not open for further replies.

gtroiano

Technical User
Nov 7, 2001
99
US
i have a form that sends email addresses from a multi-select list box to a text box on another form which is used to send emails. i currently have the following code to populate the text boxes:
Dim intItem As Integer
Dim intItem2 As Integer
Dim intItem3 As Integer

For intItem = 0 To ToBox.ListCount - 1
If ToBox.ListCount > 1 Then
Forms!frmSMTP!lstTo = Forms!frmSMTP!lstTo & ToBox.column(0, intItem) & strItem & ","
Else
Forms!frmSMTP!lstTo = Forms!frmSMTP!lstTo & ToBox.column(0, intItem) & strItem
End If
Next intItem

For intItem2 = 0 To CCBox.ListCount - 1
If CCBox.ListCount > 1 Then
Forms!frmSMTP!lstCC = Forms!frmSMTP!lstCC & CCBox.column(0, intItem2) & strItem & ","
Else
Forms!frmSMTP!lstCC = Forms!frmSMTP!lstCC & CCBox.column(0, intItem2) & strItem
End If
Next intItem2

For intItem3 = 0 To BCCBox.ListCount - 1
If BCCBox.ListCount > 1 Then
Forms!frmSMTP!lstBCC = Forms!frmSMTP!lstBCC & BCCBox.column(0, intItem3) & strItem & ","
Else
Forms!frmSMTP!lstBCC = Forms!frmSMTP!lstBCC & BCCBox.column(0, intItem3) & strItem
End If
Next intItem3

frmSMTP - the main form.
ToBox, CCBox, and BCCBox - the list boxes.
lstTo, lstCC, lstBCC - the text boxes.

the if then else statements are to put commas between the email addresses, which is necessary, but this adds am extra comma after the last email address (i.e. bob@aol.com,jesus@heaven.gov,) which prevents it from being sent. if anyone has a way around this i would be appreciative if you would let me in on it.

jerry.
 
I would say you could use an iif() to conditionally place the comma until the intItemX= .ListCount - 1 JHall
 
thanks jhall for the help. in my travels, i found the answer at thread702-29770 .

jerry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top