+ Reply to Thread
Results 1 to 13 of 13

Email multiple people based on response

Hybrid View

  1. #1
    Registered User
    Join Date
    09-27-2015
    Location
    USA
    MS-Off Ver
    2013/Office 365
    Posts
    51

    Email multiple people based on response

    I have an issue where I will make a meeting in Outlook for 80+ people and some people respond but don't send a reply so when I look in the tracking tab for the meeting I get a bunch of responses that say none because of this and it causes issues with accurate head count for meetings and catering for food.

    I want to be able to email everyone in column C that has None as the response excluding the meeting organizer since they will always be none. I also need column A to edited over the course of this. Since I use outlook's GAL it shows each user as First Last for their name like John Doe for example. Everyone in the company has first.last@domain.com as the email so I'm hoping it's possible for someone to be able to turn First Last into that email and then email the list based off if they didn't respond. I attached a sample workbook, I hope this all makes sense
    Attached Files Attached Files
    Last edited by plotting; 11-06-2015 at 03:43 PM.

  2. #2
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Email multiple people based on response

    What you want to do is possible. It will however require VBA coding. Are you familiar with VBA?
    If your questions has been answered to your satisfaction please don't forget to do the following:

    Add Reputation ... and ... Mark Thread as Solved

    Thanks,

    Ma 10:8b Freely you have received; freely give.

  3. #3
    Registered User
    Join Date
    09-27-2015
    Location
    USA
    MS-Off Ver
    2013/Office 365
    Posts
    51

    Re: Email multiple people based on response

    I figured that much, I am familiar with it just have never really used it. I've done some simple programming classes though with making a hello world "program" and other things.

  4. #4
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Email multiple people based on response

    1. In your workbook hit Alt + F11 to open the VBA editor.
    2. Find your workbook's name in the VBAProject window on the left
    3. Right click --> Insert --> Module
    4. You can rename the module if you like
    5. Double click on the newly created module
    6. Paste the following code into it

    Option Explicit
    
    Sub EmailNoReplys()
         
    Dim sSubject As String, sBody As String, sTo As String, sDomain As String
    Dim r As Integer
    Dim ThisWB As Workbook, ThisWS As Worksheet
    
    Set ThisWB = ThisWorkbook
    Set ThisWS = ThisWB.Worksheets("Sheet1") 'Change this
    sSubject = "Subject" 'Change to suit
    sBody = "Body" 'Change to suit
    sDomain = "@domain.com" 'Change to suit
    r = 2
    With ThisWS
        Do Until Trim(Cells(r, 1).Value) = ""
            If .Cells(r, 3) = "None" Then 'if Response is 'None' will need to be exactly that...not 'none' or 'none ' or 'None ' etc...
                'Build the 'To' list
                If sTo = "" Then
                    sTo = .Cells(r, 1).Value & sDomain & "; "
                Else
                    sTo = sTo & .Cells(r, 1).Value & sDomain & "; "
                End If
            End If
        r = r + 1
        Loop
    End With
    EMail sTo, sSubject, sBody, False 'Change last argument to true if you want it to send right away
    
    End Sub
    
    Function EMail(StrTo As String, _
                                  StrSubject As String, StrBody As String, Send As Boolean)
        Dim OutApp As Object
        Dim OutMail As Object
        Dim signature As String
        
        On Error Resume Next
        Set OutApp = GetObject(, "Outlook.Application")
            If Err.Number <> 0 Then
                Err.Clear
                Set OutApp = CreateObject("Outlook.Application")
            End If
        Set OutMail = OutApp.CreateItem(0)
    
        Application.ScreenUpdating = False
        With OutMail
            .Display
        End With
            signature = OutMail.HTMLBody
        Application.ScreenUpdating = True
        
        On Error GoTo ExitFunc
        With OutMail
            .To = StrTo
            .cc = ""
            .BCC = ""
            .Subject = StrSubject
            .HTMLBody = StrBody & "<br>" & signature
            If Send = True Then
                .Send
            Else
                .Display
            End If
        End With
    
    ExitFunc:
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Function
    Edit the items in the code marked "Change" or "Change to suit"!

    Now to add a button to your sheet to execute the code!
    In Office 2010 or 2013 follow these steps to add the Developer Tab if you don't have it
    1. Click on File
    2. Click on Options
    3. Click on Customize Ribbon
    4. Check "Developer" in the list on the right
    5. Click OK

    Back in your sheet...
    1. Click on the Developer Tab
    2. Click on Insert
    3. From the drop down select the top leftmost icon ... Button Form control
    4. It will create a cross hairs for you to draw the button where you want it
    5. After drawing the button a dialog will pop up for you to select the macro you want executed when the button is clicked
    6. Select your new macro's module name

  5. #5
    Registered User
    Join Date
    09-27-2015
    Location
    USA
    MS-Off Ver
    2013/Office 365
    Posts
    51

    Re: Email multiple people based on response

    Dude you're awesome, it works great except that it doesn't add "." between First Last so it's showing First <Last@domain.com> and thus just trying to email Last@domain.com

  6. #6
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Email multiple people based on response

    Two ways to correct this...
    Add the "." in column A when you type the name so it's ready for the code, or use two columns one with the first name and one with the last name and modify the code accordingly.

  7. #7
    Registered User
    Join Date
    09-27-2015
    Location
    USA
    MS-Off Ver
    2013/Office 365
    Posts
    51

    Re: Email multiple people based on response

    All the text in the sheet is from copying and pasting from the tracking tab. Sometimes they have 80+ users on the list and the person doing this would never figure it out lol. Is there a way to automate that?

  8. #8
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Email multiple people based on response

    Is there a space separating first name and last name?

  9. #9
    Registered User
    Join Date
    09-27-2015
    Location
    USA
    MS-Off Ver
    2013/Office 365
    Posts
    51

    Re: Email multiple people based on response

    Yes it will be a space for everyone in that column

  10. #10
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Email multiple people based on response

    Replace
                If sTo = "" Then
                    sTo = .Cells(r, 1).Value & sDomain & "; "
                Else
                    sTo = sTo & .Cells(r, 1).Value & sDomain & "; "
                End If
    With
                If sTo = "" Then
                    sTo = Replace(.Cells(r, 1).Value, " ", ".") & sDomain & "; "
                Else
                    sTo = sTo & Replace(.Cells(r, 1).Value, " ", ".") & sDomain & "; "
                End If
    Will only work for the email if there is one and only one space...

  11. #11
    Registered User
    Join Date
    09-27-2015
    Location
    USA
    MS-Off Ver
    2013/Office 365
    Posts
    51

    Re: Email multiple people based on response

    Genius! Thank you so much man!

  12. #12
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Email multiple people based on response

    You are most welcome!!

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Email multiple people based on response

    I realize that this post is solved and am posting this code to demonstrate Outlook's ability to lookup the names and return the email addresses from the Contact folder.

    Exchange server users often copy the GAL into their Outlook Contacts folder. This code provides a more flexible method of returning an individuals email address and other information as well.

    This will send emails to those people in the list that meet the following criteria: Attendance =" Required" and Response = "None". The subject line and email message need to be modified for your email needs.
    Sub SendEmailList()
    
        Dim Cell        As Range
        Dim Contacts    As Object
        Dim EmaiAddx    As String
        Dim EmailList   As String
        Dim FirstName   As String
        Dim LastName    As String
        Dim Message     As String
        Dim olApp       As Object
        Dim Rng         As Range
        Dim Subject     As String
            
          ' Fill these in with what you want in your email.
            Subject = "Test email"
            Message = "This sends the same email to multiple people."
            
            Set Rng = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
            
            Set olApp = CreateObject("Outlook.Application")
            
            Set Contacts = olApp.Session.GetDefaultFolder(10).Items
            
            For Each Cell In Rng
                If Cell <> "" And Cell.Offset(0, 1) Like "Required*" And Cell.Offset(0, 2) = "None" Then
                    arr = Split(Cell, " ")
                    FirstName = arr(LBound(arr))
                    LastName = arr(UBound(arr))
                
                    On Error Resume Next
                        EmailAddx = Contacts.Find("[FirstName] = '" & FirstName & "' and [LastName] = '" & LastName & "'").Email1Address
                        
                        If Err <> 91 And Err <> 0 Then
                            MsgBox "Run-time error '" & Err.Number & "':" _
                                    & vbLf & vbLf & Err.Description, _
                                    vbOKOnly + vbExclamation, "Outlook - Emails Not Sent"
                            Exit Sub
                        End If
                        
                        If Err = 0 Then EmailList = EmailList & EmailAddx & ";"
                    On Error GoTo 0
                End If
            Next Cell
            
            If EmailList <> "" Then
                With olApp.CreateItem(0)
                    .To = EmailList
                    .Subject = Subject
                    .Body = Message
                    .Send
                End With
            End If
            
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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 Direct Replies To Different People Based on Voting Button Response
    By mjeffery in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2015, 12:39 PM
  2. Email Excel worksheets to multiple people per tab
    By cooket4 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2015, 09:42 AM
  3. Code to Email Specific People Based on ComboBox Selection
    By esanvilla in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2015, 10:08 AM
  4. Looking to alert/email certain people on certain dates based on excel data
    By Wooodd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2015, 08:52 AM
  5. [SOLVED] Sending email to different people based on the value in a cell
    By subbby in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-18-2013, 11:53 AM
  6. [SOLVED] Email to multiple people in a sheet
    By shoopes2 in forum Excel General
    Replies: 3
    Last Post: 12-28-2012, 02:10 AM
  7. email multiple spreadsheets to multiple people
    By beatrice25 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2008, 02: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