Listbox not showing in sent email

jcgraham0007

New Member
Joined
Jun 21, 2020
Messages
10
Office Version
  1. 2016
  2. 2013
  3. 2010
  4. 2007
Platform
  1. Windows
Can anyone help. I've created a userform and everything functions as it should.

However when I send the email using the command button, the email arrives buts is missing any listbox information.

I've created a formula which will display cell data based on a range in a worksheet.

I've done similar with combobox drop down boxes and the data arrives fine.

The email is sent as plain text but whatever I try I can't get listbox info to show

My Code as follows

Private Sub CommandButton2_Click()
Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String

Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)

'set Importance
aEmail.Importance = 1
'Set Subject
aEmail.Subject = "Planned Lock Request Change"
'Set Body for mail
aEmail.Body = "Promised Delivery Date: " & Me.TextBox1.Value & Chr(10) & _
"Person Making the Request: " & Me.ComboBox1.Value & Chr(10) & _
"Reason For Making the Request: " & Me.ComboBox2.Value & Chr(10) & _
"Customer Name: " & Me.ComboBox3.Value & Chr(10) & _
"Order Number: " & Me.TextBox8.Value & Chr(10) & _
"Customer Tier Level: " & Me.TextBox2.Value & Chr(10) & _
"Total Cost of the Order: " & Me.TextBox3.Value & Chr(10) & _
"Product Code: " & Me.ComboBox6.Value & Chr(10) & _
"Product Name and Pack Size: " & Me.ListBox2.Value & Chr(10) & _
"Quantity: " & Me.TextBox5.Value & Chr(10) & _
"Product Code: " & Me.ComboBox7.Value & Chr(10) & _
"Product Name and Pack Size: " & Me.ListBox3.Value & Chr(10) & _
"Quantity: " & Me.TextBox6.Value & Chr(10) & _
"Product Code: " & Me.ComboBox8.Value & Chr(10) & _
"Product Name and Pack Size: " & Me.ListBox4.Value & Chr(10) & _
"Quantity: " & Me.TextBox7.Value & Chr(10) & _
"Notes: " & Me.TextBox4.Value

'send one off to 1 person use this static code
'aEmail.Recipients.Add " "
aEmail.Recipients.Add " "
'Send Mail
aEmail.Send
End Sub

Thanks in Advance
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I would explain it this way: a combo or a textbox is a like bucket with one marble in it. That's why you can send its contents. A listbox is like a bucket of marbles, which you can't send en masse (at least not as far as I know). But you can loop over the list and send all the items in some other form (e.g. a string variable or set of variables), or you can retrieve one list item from it and send that. If you want to get the selected item from the listbox you can use its .ListIndex property value. To get a value from the nth row, use .List ( 0 , 0 ) property value. I had to insert spaces there to avoid getting a thumbs down emoji, yet not on the second example (??). That assumes the lb has only one column. If not, you will need to include the column number. Both properties are zero based collections, so first row and column is (0,0).

As an aside, after years of doing this, old codgers like me look at code posted like that and the eyes just glaze over 🥴.
Please post code between code tags (use vba button on posting toolbar) with proper indentation.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top