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.
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.