Private Sub Send_Click() Dim dbsheet As Worksheet Set dbsheet = ThisWorkbook.Sheets("get") lr = dbsheet.Cells(Rows.Count, 1).End(xlUp).Row SelRow = Selection.Row BatchId = dbsheet.Cells(SelRow, 1) 'Declare variables' Set objMyConn = New ADODB.Connection Set objMyRecordset = New ADODB.Recordset Dim strSQL As String 'Open Connection' objMyConn.ConnectionString = "Provider=SQLOLEDB;Data Source=abc;Initial Catalog=abc;User ID=sa;Password=abc;" objMyConn.Open 'Set and Excecute SQL Command' strSQL = "select EMail_1 from Student_Info where Branch_Code='ap' and Student_ID in ( select Student_ID from Admissions where Branch_Code='ap' and Batch_ID=BatchId)" Dim olApp As Outlook.Application Set olApp = CreateObject("Outlook.Application") Dim olMail As Outlook.MailItem Set olMail = CreateItem(olMailItem) olMail.To = "My MailID@gmail.com" ' Here I'm facing Problem how to attach mails to BCC for olMail.BCC = "" olMail.Subject = "Subject Line" olMail.Body = "This is test Mail" olMail.Send End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)