+ Reply to Thread
Results 1 to 19 of 19

Put listbox items into email body

  1. #1
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Put listbox items into email body

    I have a userform to create an email. It generates the email body from textbox values within the userform. My problem is getting the listbox items into the email body.

    Here are my code

    Please Login or Register  to view this content.
    After "please see attached" in the email body I would like the listbox items to go in there so the email reads;

    Hi John,

    Re: Project 1

    Thank you for the opportunity to tender for the above project. Please see attached:

    • Price BOQ
    • Quality Submission
    • Case Studies
    • Programme

    Please do not hesitate to contact me should you have any queries.

    The "Price BOQ, Quality Submission, Case Studies, Programme" is just for this example but will be completely different for each email. I select checkboxes to populate the listbox with these items

    Thanks for any help with this!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Put listbox items into email body

    How are you currently setting the body of the email?

    To get a list of the selected items from the listbox you should probably use HTML and use the HTMLBody property for the email body.

    This function will return the HTML for an unordered (or unordered) list based on the selected items in the listbox, lst, passed to it.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Put listbox items into email body

    Hi Norie,

    Thank you for your reply.

    I have a textbox on the userform named txtboxBody. It is populated by running my code above on a click event.

    I then have an email button that runs another code but it wont let me upload it.

    Its with Createobject code and it has .HTMLbody = userform txtboxbody in it

    How do I incorporate your code into mine then?

    Thanks Norie!

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Put listbox items into email body

    See if this gets you anywhere.

    Select a folder with some XL-files. Put Name & Subject. Select 1 or more items in Listbox & click Generate Email.
    Attached Files Attached Files
    Last edited by bakerman2; 10-05-2019 at 02:04 AM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Put listbox items into email body

    Bakerman2,

    Sorry for the late reply, I had to work away from home and only back.

    Brilliant code as always. Could you get it to put selected folders as attachments in the emails also?

    Thanks bakerman2 and sorry again for only getting back to you now

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Put listbox items into email body

    Norie did the most part of the work with his function.

    I simply adapted it to work also when only 1 item is selected on the Listbox.

    As for your added request I had to put the code in a textfile due to blocking by Succuri (HTML Tags)
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Put listbox items into email body

    I have attached a file to show you what I am trying to achieve.

    Can't quite get it working but its nearly there!
    Attached Files Attached Files

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Put listbox items into email body

    Let's start with this one and work our way up.

    Select Project, fill in To, CC, Name fields and select Bulletpoints. Then click Email button.

    The Attachment Textbox serves what purpose ??

    I can't see the added value of the body Textbox since you're only showing a preformatted vba text ??
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Put listbox items into email body

    My idea was to create the whole email via userform. For the attachments box I was thinking I could click this box and it takes me to the project folder on J:/ and I can select the files I want to attach to the email.

    For the body textbox I was wanting to add the standard preformatted text for all emails and then manually add more text to the email depending on the requirements for each project.

    Can the email include my email signature at the bottom?

    Thanks

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Put listbox items into email body

    Test this one. DoubleCilck the Attachments Listbox to open FilePicker, which you can Multiselect.

    BodyTextbox Text can also be changed.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Put listbox items into email body

    Bakerman2,

    brilliant as usual!!

    Thank you

  12. #12
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Put listbox items into email body

    Only one wee thing. It brings up an error if there is nothing in the bullet points listbox.

    Sometimes there will be no bullet points on the email so could this work if nothing is selected?

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Put listbox items into email body

    Add this to the start of the ListToHTML function.
    Please Login or Register  to view this content.

  14. #14
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Put listbox items into email body

    This should do it.
    Attached Files Attached Files
    Last edited by bakerman2; 10-17-2019 at 09:26 PM.

  15. #15
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Put listbox items into email body

    Thanks bakerman2 and Norie!

  16. #16
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Put listbox items into email body

    You're welcome and thanks for rep+.

  17. #17
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Put listbox items into email body

    @ bakerman2,

    I have allowed you to collect a lot of Rep+ "Taps". Mind to share some, or else!
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  18. #18
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Put listbox items into email body

    OMG Tjaart, are you really trying to steal my moment of glory here ???

    Keep up this behaviour and a good spanking will be your reward my friend.

  19. #19
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Put listbox items into email body

    Sticks and stones.....Rudi

    Great to have a friend like you, threatening me with a spank you.

    Spank you sooo Much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 02-11-2019, 08:45 AM
  2. Macro to put Items in array for email body HELP PLEASE!
    By cory0789 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2016, 10:09 PM
  3. [SOLVED] Pass multiselect listbox data to email body
    By pjbassdc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-25-2015, 03:35 PM
  4. Send New Email W/ Body of Received Email, Then Delete Sent Email
    By edneal2 in forum Outlook Formatting & Functions
    Replies: 2
    Last Post: 07-01-2013, 12:45 AM
  5. [SOLVED] Auto select items in a Listbox with items from another Listbox
    By perducci in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-22-2013, 04:45 PM
  6. Using pivot items from multiple pivot fields within email body generated from VBA
    By GregUnsworth in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-01-2013, 11:10 AM
  7. Transfer random listbox items to new listbox and then loop through selected items
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2013, 05:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1