Mail sent to Multiple users

     

     

    Sub Send_A_Mail_To_Multiple_Mailids()
    'Created Object variable SH for worksheet2
    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets("Sheet2")
    'Defined the last row
    Dim Lastrow As Integer
    Lastrow = sh.Range("B" & Rows.Count).End(xlUp).Row
    'Defined the variable to store the mailids
    Dim Mail_Ids As String
    For i = 2 To Lastrow
    Mail_Ids = Mail_Ids & sh.Cells(i, 2).Value & ";"
    'MsgBox Mail_Ids
    Next
    'Display the complete list of mail ids on msgbox
    MsgBox Mail_Ids
    'Defining Outlook Object
    Dim O As Outlook.Application
    Set O = New Outlook.Application
    'Connecting to Email through Outlook object
    Dim E As Outlook.MailItem
    Set E = O.CreateItem(olMailItem)
    'Connecting to email Properties
    With E
    .To = Mail_Ids
    .CC = "pavankumargundlapalli@gmail.com"
    .Subject = "Invitation to School Inauguration" .BodyFormat = olFormatPlain
    .Body = "Hi" & vbNewLine & _
    "Please join with us to Inauguration function"
    .Importance = olImportanceHigh
    .Display
    .Send
    End With
    End Sub

     

    Download The Workbook