+ Reply to Thread
Results 1 to 27 of 27

Need VBA code to Send Formatted Table from Excel via Email using Outlook

  1. #1
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Need VBA code to Send Formatted Table from Excel via Email using Outlook

    hello there,

    Can someone please help me?

    I'd like to automate with VBA sending an email to multiple recipients.
    The email's body must say the text below and then copies and pastes the formatted table you see on the attachment (Columns A to H):

    Hello All,

    Month End is finally here. Please find below summary of your missing hours.
    As there are multiple recipients, I'd like to email to be sent from the Bcc: field so replies are not sent to all recipients.

    The Subject on the email must read:

    ***You have Missing Time***
    Do you think that's possible to do? The recipients' email addresses show up on column I.
    Attached Files Attached Files
    Last edited by alchavar; 10-21-2020 at 09:18 AM. Reason: Forgot to mention something

  2. #2
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Do you want to send the email in Outlook or something like gmail? It is very possible to do this.

  3. #3
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    hi maniacb,

    Thanks for asking. If possible, I'd like to send the email from Excel without having to open my Outlook application.

    Also, just to let you know: most users are currently using Outlook as that's my company's software. But as we have contractors working for us, I want some of them to receive the email at their personal email address also indicated on Column I.

    Hope that makes sense.

  4. #4
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Do you want to add a column with the date value of when the email was created? So that you know if it was sent?

  5. #5
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    That would be awesome!!! Yes, please. If possible, can I also receive the email? Let's put my personal email on the code for now. I'll change it later. The email is: [email protected]

  6. #6
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Here is the code. and the working file. Email also sent

    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    hi maniacb,

    Can you adjust the code a bit? The code is creating draft emails but is not sending them over to the recipients.

    Also, instead of sending multiple emails (one to each recipient), could we just send one email with the whole table embedded on it?

    And lastly, can we put the body of the email on a separate row? It currently shows this:

    Hello All, Month End is finally here. Please find below summary of your missing hours.


    Can we make it like this?

    Hello All,

    Month End is finally here. Please find below summary of your missing hours.

  8. #8
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Also, instead of sending multiple emails (one to each recipient), could we just send one email with the whole table embedded on it?
    On this point, which email o you want to send the one email to? The first one in the line, so there is no loop, or do you want to send the whole table to each email?

  9. #9
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    hi manicb,

    Correct. My intention is to just send one single email. So all the email addresses on column I should be on the Bcc: field in Outlook. All recipients will get the full table (not just the row with their missing time).

    Also, can you put my email address on the Cc: field? [email protected]

  10. #10
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Here you go. The email will be sent without first displaying it

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by maniacb; 10-21-2020 at 03:30 PM. Reason: Corrections to response

  11. #11
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    hi maniacb,

    Thank you so much.

    One more thing:

    Attachment 700745

    As you can see, I have to manually send the email. Can you modify the code one last time so that:

    -I don't have to see the email displayed in Outlook
    -the email is sent automatically from Excel (me not having to click Send on Outlook)?
    Last edited by alchavar; 10-21-2020 at 04:32 PM.

  12. #12
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Your attachment didn't come through. Attachments work on the second attempt on this site. Try it again

  13. #13
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Sorry for that! Let me know if you get it this time.

    I had to insert is an image because the option for attaching files I no longer see it activated.

    Attachment 700761

  14. #14
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    to attach a file, select the Go Advanced option

  15. #15
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Thank you. Here you go!
    Attached Images Attached Images

  16. #16
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    The code as written in post #10 should not be displaying the email. Try deleting the line below and re-running the code.

    '.Display 'DELETE THIS LINE IF USING SEND

  17. #17
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    I am afraid is not working. I deleted the line as you said and it didn't do anything. Can you try sending it to yourself and see if it works for you? Here's the Excel file with the code from post #10 without the line '.Display 'DELETE THIS LINE IF USING SEND

  18. #18
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Sorry. Forgot to attach the file.

  19. #19
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    On your code, the send line has a an apostrophe in front. Remove that apostrophe.

    so the code should look like:

    Please Login or Register  to view this content.

  20. #20
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    It worked! Thank you so much.

    One last thing (I promise): how can I create a new line on the body so that the greeting and the rest of the message show on separate lines like this?:

    Hello All,

    Month End is finally here. Please find below summary of your missing hours.



    The email is being sent with one single line:

    Hello All, Month End is finally here. Please find below summary of your missing hours.

  21. #21
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Sorry! Forgot to ask you: I generate this report from another workbook that has multiple worksheets. If I want to embed the code that you so kindly generated for me, how can I make it suitable for that spreadsheet on that workbook? Let's say that the name of the worksheet where the report is found is Missing Time Report.
    Last edited by alchavar; 10-21-2020 at 09:29 PM.

  22. #22
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    I updated the code to work on any sheet, the activesheet. But it assumes all the cells are in the same position.

    Please Login or Register  to view this content.
    As for the initial body data all being on one line, Let me think about that.

  23. #23
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Great! It worked. Thank you so much. Now just awaiting the fix to break the body into 2 lines. Take your time. No rush!

  24. #24
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Try this

    Please Login or Register  to view this content.

  25. #25
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    I did, but it's still not working.
    Attached Images Attached Images

  26. #26
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Let's try a different approach

    Please Login or Register  to view this content.

  27. #27
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Need VBA code to Send Formatted Table from Excel via Email using Outlook

    Unfortunately, it's still not working. I got the same result as on post #25.

+ 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. VBA code to make Excel send an email via Outlook
    By vanni in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-27-2015, 06:26 AM
  2. How to send formatted email without outlook
    By alex188 in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 05-15-2015, 05:09 AM
  3. [SOLVED] Requesting VBA code to automatically send email through Outlook from Excel
    By Colton4 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2015, 07:15 PM
  4. Email .pdf attachment using Outlook and send formatted message.
    By shawnvon in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-02-2014, 03:17 PM
  5. Send data table from Excel to outlook as Email
    By praky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-16-2014, 04:31 PM
  6. Send formatted email from excel
    By matchooo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-09-2013, 09:08 PM
  7. [SOLVED] VBA code - automatically open outlook to send email
    By LindaABH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-06-2012, 01:44 AM

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