+ Reply to Thread
Results 1 to 9 of 9

VBA to send email

  1. #1
    Registered User
    Join Date
    09-20-2013
    Location
    Hartland, WI
    MS-Off Ver
    Excel 2013 Professional Plus
    Posts
    73

    VBA to send email

    I need a vba that sends a multiple different range to a different recipient for each range.

    For example, I have a range in A1-F30, with an email address and subject in H14:H15.
    Then a different range in A32:F62, with a different email address and subject in H45:H46
    And so on with possibly 100 different ranges and email addresses.

    Is there a vba that will send a different email to all of those email addresses, with the range in the body of the email?
    Last edited by gillyr7; 01-03-2014 at 11:47 AM.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: VBA to send email

    I don't see a pattern to the ranges you want to send. How are they determined?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    09-20-2013
    Location
    Hartland, WI
    MS-Off Ver
    Excel 2013 Professional Plus
    Posts
    73

    Re: VBA to send email

    Basically 30 rows, skip a row, 30 rows, skip a row...

    A1:F30 Range 1
    A32:F62 Range 2
    A64:F94 Range 3
    A96:F126 Range 4
    ... (Possible >100 Ranges)

    The H range can go anywhere to the right of each range. That does not matter. Whatever is easiest I guess.

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: VBA to send email

    Okay. If you place the required email address in the first row of the range it might be easier.

    Can you attach a workbook with an example of how your data is laid out?

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA to send email

    Hi,

    I'm assuming the 2nd, 3rd & subsequent ranges were typos since they are all 31 rows.
    So if you mean A1:F30, A32:F61, A63:F90 etc. and with the email address for each range in H1, H32, H63 etc. then this is an example of code I am using in several workbooks - adapted for your ranges

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  6. #6
    Registered User
    Join Date
    09-20-2013
    Location
    Hartland, WI
    MS-Off Ver
    Excel 2013 Professional Plus
    Posts
    73

    Re: VBA to send email

    Test Sample.xlsx


    A small sample is attached. Notice how a range might not have 30 rows total. The following range would still act as if the previous range contained all 30 rows.

    The email that ends up going out can send all 30 rows no matter what, but it would be nice to only send rows with data in them. Not necessary though.

  7. #7
    Registered User
    Join Date
    09-20-2013
    Location
    Hartland, WI
    MS-Off Ver
    Excel 2013 Professional Plus
    Posts
    73

    Re: VBA to send email

    Richard, that is exactly what I need. Thank you. Is there a way to send each range as an attachment, instead of in the body of the email?

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA to send email

    Hi,

    Your original post specifically asked for the range to be included in the body of the email, and in addition you specifically said that all ranges were the same size, which is why I sent you what I did. Now seemingly as well as an attachment being required, the ranges are not the same size either.

    When seeking help it's important that you are quite clear what you really want otherwise we all waste our time.

    Are you now asking if you can generate an Outlook email with an attachment. If so then each range will have to be copied to a new workbook, saved as a file and then attached. Is this additional complexity what you really want?
    Last edited by Richard Buttrey; 01-03-2014 at 11:44 AM.

  9. #9
    Registered User
    Join Date
    09-20-2013
    Location
    Hartland, WI
    MS-Off Ver
    Excel 2013 Professional Plus
    Posts
    73

    Re: VBA to send email

    I needed the range in each email per my original post.

    I will mark this as answered as what you provided was perfect.

    However, there is a future project that I will want the attachments included instead of the range in the body. I will open a new thread for that with a link back to this one. Feel free to answer that one, but thank you for your help so far.

+ 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: 1
    Last Post: 09-09-2013, 03:46 PM
  2. 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
  3. send selected range in email with default outlook email signature included
    By mdsickler in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-04-2013, 10:50 PM
  4. Automatic send email (without even click send in mail software) with excel vba ??
    By alexnkc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-17-2013, 08:31 PM
  5. Code to send Email wont send everytime
    By tanktata in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-11-2011, 04:44 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