+ Reply to Thread
Results 1 to 12 of 12

VBA auto outlook 2016 to send e-mail based off criteria

  1. #1
    Registered User
    Join Date
    01-26-2017
    Location
    Tampa, FL
    MS-Off Ver
    excel 2007
    Posts
    14

    VBA auto outlook 2016 to send e-mail based off criteria

    VBA select/send email based off criteria

    Don't know how to accomplish this as i've never coding in e-mails for outlook

    I have cell below A-AA where the word "column" begins on row 4

    For columns T-Z, if any cell is highlights in that certain row as RGB(252,213,180), then draft e-mail that corresponds to column L's row

    The data will change week over week but the worksheet will stay the same

    Email would be something like

    from : supplychain
    to : corresponding cell
    subject : forecast change
    body : Hi, there is a forecast change, please take a look at your highlighted changed.
    In the body or attachment I would like to show only that corresponding row...that way the other suppliers don't see eachothers data.

    Hope that makes sense. I have included the worksheet as well attached.

    Anything to help would be great!


    WEEKLY FORECASTED NEEDS
    New Items Added to Grid Highlighted in This Color
    PRODUCT INFORMATION WAREHOUSE INFORMATION
    Concept Promo Name Start Date End Date Duration of Promo (in Days) Obosolete/Reduced Item Check In Date Category Product Item Number Case Size Column Column Column Column Column Column Column Column Column Column Column Column Column Column Column Column Column
    zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz [email protected] zzz zzz zzz zzz zzz zzz zzz 22 20 76 34 39 22
    zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz [email protected] zzz zzz zzz zzz zzz zzz zzz 26 23 88 40 45 26
    zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz [email protected] zzz zzz zzz zzz zzz zzz zzz 166 49
    zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz [email protected] zzz zzz zzz zzz zzz zzz zzz 13 12 46 21 24 14
    zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz [email protected] zzz zzz zzz zzz zzz zzz zzz 15 13 50 22 26 15
    zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz [email protected] zzz zzz zzz zzz zzz zzz zzz 48 43 75 85
    zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz [email protected] zzz zzz zzz zzz zzz zzz zzz 18 16 28
    zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz [email protected] zzz zzz zzz zzz zzz zzz zzz 61 32 18
    zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz zzz [email protected] zzz zzz zzz zzz zzz zzz zzz 174 154 595 268 306 175
    zzz zzz zzz zzz zzz zzz

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA auto outlook 2016 to send e-mail based off criteria

    The attached code is a subroutine that works with Outlook and takes the following arguments
    - To string (mandatory) - the list of people in the TO: block of the email
    - Subject String (mandatory) - the subject of the email
    - Body String (mandatory) - the body of the message
    - CC String (optional) - the list of people in the CC: block of the email
    - BCC String (optional) - the list of people in the BCC: block of the email
    - Attachment Name (optional) - the file to attach to the email

    Do what you need to do to calculate these parts and pass them to the subroutine.

    Please Login or Register  to view this content.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    01-26-2017
    Location
    Tampa, FL
    MS-Off Ver
    excel 2007
    Posts
    14

    Re: VBA auto outlook 2016 to send e-mail based off criteria

    thank you, but does that take into account that the e-mail address need is essential an if/then statement of RGB within a loop down a range?

    I also only want to send out that row range that corresponds...make sense?

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA auto outlook 2016 to send e-mail based off criteria

    It doesn't make sense since I don't have a workbook to look at.

    I can help you along with that if you include a workbook.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  5. #5
    Registered User
    Join Date
    01-26-2017
    Location
    Tampa, FL
    MS-Off Ver
    excel 2007
    Posts
    14

    Re: VBA auto outlook 2016 to send e-mail based off criteria

    I think I attached it right this time. appreciate the help
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-26-2017
    Location
    Tampa, FL
    MS-Off Ver
    excel 2007
    Posts
    14

    Re: VBA auto outlook 2016 to send e-mail based off criteria

    appreciate it. did i attached correctly?
    Attached Files Attached Files

  7. #7
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA auto outlook 2016 to send e-mail based off criteria

    I need confirmation more than clarification. I go down row by row. If anything in column T:Z on that row is the correct RGB color, prepare an email to the address in column L.

    I transmit the header row and just that one row with the data.

    I might be able to do one better. It depends on your answer. Will there be a lot of the same email address in Column L or is it pretty much one row per customer.

    If it’s one row per customer, I’ll just process linearly. On the other hand, if some customers have multiple rows, I can collect them all together and send out one email per customer.

    Also, how are you getting this data in? Are you copy and pasting the data in or is this a report you just “get?” The reason I ask is that the code has to “live” somewhere.

    If you are copy / pasting the data in, then the code can live in the workbook that the data are pasted to.

    If you are getting this as a report, then I can make this a stand-alone report that opens the report file (all it needs to know is what its name is) and process it.

  8. #8
    Registered User
    Join Date
    01-26-2017
    Location
    Tampa, FL
    MS-Off Ver
    excel 2007
    Posts
    14

    Re: VBA auto outlook 2016 to send e-mail based off criteria

    Thanks for the quick response. I'll try and answer below

    I go down row by row. If anything in column T:Z on that row is the correct RGB color, prepare an email to the address in column L - yes

    I transmit the header row and just that one row with the data - Yes and that would be in the subject of the e-mail

    I might be able to do one better. It depends on your answer. Will there be a lot of the same email address in Column L or is it pretty much one row per customer - If you can do one per customer that would be amazing

    If it’s one row per customer, I’ll just process linearly. On the other hand, if some customers have multiple rows, I can collect them all together and send out one email per customer. - If you can do one per customer that would be amazing

    Also, how are you getting this data in? Are you copy and pasting the data in or is this a report you just “get?” The reason I ask is that the code has to “live” somewhere. - The code can live in the workbook

    If you are copy / pasting the data in, then the code can live in the workbook that the data are pasted to. - the code can live in the workbook

    If you are getting this as a report, then I can make this a stand-alone report that opens the report file (all it needs to know is what its name is) and process it. - No need

    Only other ask would be that the amount of rows may change over time...so it would be advantageous to loop through all the rows until the last row for both sheets ("Active Auto Ship Items") and ("Active Weekly Forecast Items") worksheets

    Thanks again
    Adam

  9. #9
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA auto outlook 2016 to send e-mail based off criteria

    I think I have enough to get started. I'll get to this on Monday.

  10. #10
    Registered User
    Join Date
    01-26-2017
    Location
    Tampa, FL
    MS-Off Ver
    excel 2007
    Posts
    14
    Quote Originally Posted by dflak View Post
    I think I have enough to get started. I'll get to this on Monday.
    Thank you so much! Let me know if you need any help. If its to hard to group the email per change then 1:1 linear as you spoke about before will work too. Grouped is just a bonus. Thx!

  11. #11
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA auto outlook 2016 to send e-mail based off criteria

    Here is an intermediate file. There are a couple of thing I still need to tidy up. Some features I put in are that the Shipping and Forecast sheets are now Excel Tables. I added a column (which can be hidden) to determine if there are cells shaded red.

    The way the program works is that I concatenate the addresses from both tables and run a pivot table off the concatenated list to get a unique list of addresses.

    I took the Ship Table and Forecast Table and built pivot tables off of them. The pivot table does the bulk of the work of grouping the emails so you are not sending the information out piecemeal. I do some checking and I set the pivot table filters to look at the records for one email address at a time where Has Color is TRUE.

    Then I copy these onto a report sheet.

    Currently this part of the program is "stubbed out" when you run the MakeReport macro, a message box pops up stating that the report will be mailed. You can take a look at what the outgoing attachment will look like.

    What is left to do is to copy the report sheet to a separate spreadsheet and to hook up the mail program.

    Take a look at what the outgoing attachments will look like and give me feedback. I'll press on with it after I'm sure I'm going in the right direction.
    Attached Files Attached Files

  12. #12
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA auto outlook 2016 to send e-mail based off criteria

    Here is an intermediate file. There are a couple of thing I still need to tidy up. Some features I put in are that the Shipping and Forecast sheets are now Excel Tables. I added a column (which can be hidden) to determine if there are cells shaded red.

    The way the program works is that I concatenate the addresses from both tables and run a pivot table off the concatenated list to get a unique list of addresses.

    I took the Ship Table and Forecast Table and built pivot tables off of them. The pivot table does the bulk of the work of grouping the emails so you are not sending the information out piecemeal. I do some checking and I set the pivot table filters to look at the records for one email address at a time where Has Color is TRUE.

    Then I copy these onto a report sheet.

    Currently this part of the program is "stubbed out" when you run the MakeReport macro, a message box pops up stating that the report will be mailed. You can take a look at what the outgoing attachment will look like.

    What is left to do is to copy the report sheet to a separate spreadsheet and to hook up the mail program.

    Take a look at what the outgoing attachments will look like and give me feedback. I'll press on with it after I'm sure I'm going in the right direction.
    Attached Files Attached Files
    Last edited by dflak; 01-30-2017 at 04:41 PM.

+ 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. [SOLVED] Send mail based on criteria met within active sheet
    By ANDREAAS in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-10-2016, 08:20 AM
  2. [SOLVED] Code to send mail copying from Excel to a new outlook mail.
    By paz1987 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-11-2015, 07:54 AM
  3. Macro to send e-mail based on multiple criteria
    By KatyPRB in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-17-2015, 11:19 AM
  4. Based on Birthdate in excel , Automatically send outlook mail with birthday wishes
    By ajaypal.sp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2015, 08:28 PM
  5. Send e-mail with image on body (.html) on e-mail manager <> outlook
    By mariotnc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2012, 09:28 PM
  6. Filter based on today's date and send mail in outlook
    By kandanuru in forum Excel General
    Replies: 0
    Last Post: 06-15-2012, 04:59 AM
  7. Send Mail Merge Auto-Emails based on date
    By Phillycheese5 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2005, 11:40 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