Results 1 to 11 of 11

Sending two different emails to two different recipients with single button using vba

Threaded View

ahowe Sending two different emails... 12-23-2013, 06:48 PM
Leith Ross Re: Sending two different... 12-23-2013, 07:18 PM
ahowe Re: Sending two different... 12-23-2013, 07:24 PM
Leith Ross Re: Sending two different... 12-23-2013, 07:32 PM
Leith Ross Re: Sending two different... 12-23-2013, 07:42 PM
ahowe Re: Sending two different... 12-23-2013, 07:50 PM
ahowe Re: Sending two different... 12-23-2013, 07:55 PM
Leith Ross Re: Sending two different... 12-23-2013, 07:51 PM
Leith Ross Re: Sending two different... 12-23-2013, 08:03 PM
ahowe Re: Sending two different... 12-23-2013, 08:23 PM
ahowe Re: Sending two different... 12-23-2013, 08:28 PM
  1. #1
    Registered User
    Join Date
    12-23-2013
    Location
    houston
    MS-Off Ver
    excel 2013
    Posts
    6

    Sending two different emails to two different recipients with single button using vba

    Hello,

    I am trying to use one button to send multiple emails to two different people. The messages and email addresses are in cells in the spread sheet, so I refer to them as ranges. When I click the button, the first email goes out perfectly, but the second one never sends. Can someone please help me? Here is what I have so far:
    Private Sub FillOutNewHireForm_Click()
    
        Dim OutApp As Object
        Dim OutMail As Object
        Dim Body1 As Range
        Dim Body2 As Range
        Dim Hire As Range
        Dim Email1 As Range
        Dim Email2 As Range
        
        
        Set Email1 = Worksheets("Tasks").Range("K5")
        
        Set Email2 = Worksheets("Tasks").Range("L5")
        
        Set Hire = Worksheets("Tasks").Range("C1")
    
        Set Body1 = Worksheets("Tasks").Range("F5")
        
        Set Body2 = Worksheets("Tasks").Range("G5")
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
    
        On Error Resume Next
        With OutMail
            .To = Email1
            .CC = ""
            .BCC = ""
            .Subject = "New-Hire task: Fill out New-Hire Form for " & Hire
            .Body = Body1
            .Attachments
             'You can add other files also like this
             '.Attachments.Add ("C:\test.txt")
    
            .Send
            
        End With
       
       
        On Error Resume Next
        With OutMail
            .To = Email2
            .CC = ""
            .BCC = ""
            .Subject = "New-Hire task: Please share Personal Folder with " & Hire
            .Body = Body2
            .Attachments
             'You can add other files also like this
             '.Attachments.Add ("C:\test.txt")
    
            .Send
        End With
        On Error GoTo 0
        
        
        MsgBox ("Email Sent")
        
        Range("A5").Value = "Complete"
        
        ThisWorkbook.Save
        
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub
    Last edited by Leith Ross; 12-23-2013 at 07:14 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Sending Outlook emails from Excel; Limits to three emails only?
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2013, 06:53 AM
  2. sending emails using macro button from excel, with variable data
    By GShep in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2012, 06:15 AM
  3. Sending macro emails using excel: Send emails with their passwords.
    By loveisblind in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2009, 03:16 PM
  4. Delay sending to multiple recipients from one message
    By Reema in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 02-27-2009, 02:37 AM
  5. Sending Attachments to multiple recipients
    By Prabha in forum Excel General
    Replies: 3
    Last Post: 01-24-2005, 12:06 PM

Tags for this Thread

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