Results 1 to 2 of 2

Send email to multiple recipients

Threaded View

  1. #1
    Registered User
    Join Date
    03-24-2009
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    1

    Send email to multiple recipients

    Im trying to send it to 2 people.

    This is my code:


    Sub Clear_Click()
    Range("A7:B56").ClearContents
    Range("D7:D56").ClearContents
    End Sub
    Sub SendeMail()
    Dim sendTo(2) As String
    
    
    Dim msg, sendSub As String
    
    Application.ScreenUpdating = False
    msg = "Pl. pick your clinic before clicking on this button!!"
    If ActiveSheet.Cells(2, 2) = "Pl. pick your clinic" Then
    MsgBox msg
    Exit Sub
    End If
    msg = "Pl. enter a new PO# before clicking on this button!!"
    If ActiveSheet.Cells(2, 4) = "Pl. enter a new PO#" Then
    MsgBox msg
    Exit Sub
    End If
    sendTo(0) = "[email protected]"
    sendTo(1) = "[email protected]"
    
    sendSub = "Clinic: " & Worksheets("Purchase Order").Cells(2, 2) & _
               " PO#: " & Worksheets("Purchase Order").Cells(2, 4) & _
               " Dated: " & Format(Cells(3, 4).Value, "dd-mmm-yy")
    
    'Add a worksheet
    Worksheets.Add After:=Sheets(Sheets.Count)
    'Copy the data from Purchase Order
    Worksheets("Purchase Order").Activate
    Worksheets("Purchase Order").Range("A1:D60").Copy
    Worksheets(Sheets.Count).Activate
    'Paste formats and values
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Selection.Columns.AutoFit
        Range("A1").Select
    
    'Create a new Workbook Containing the active Sheet
    ActiveSheet.Copy
    Application.CutCopyMode = False
    
    'Delete the buttons
    For Each shp In ActiveSheet.Shapes
     shp.Delete
    Next
    
    With ActiveWorkbook
    'Send as an attachment by eMail
    .SendMail Recipients:=sendTo, _
              Subject:=sendSub
    'Don't save changes
     .Close SaveChanges:=False
    End With
    Application.DisplayAlerts = False
    Worksheets(Sheets.Count).Delete
    Application.DisplayAlerts = True
    Worksheets("Purchase Order").Activate
    Application.ScreenUpdating = True
    End Sub
    Last edited by VBA Noob; 03-24-2009 at 03:13 PM. Reason: Added code tags as per forum rules

Thread Information

Users Browsing this Thread

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

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