How to attach mail Id's to BCC
I have 150 contacts in my table, I need to Mail an attachments to all of
them at a time for that reason i would like to add all of them in BCC
dynamically.
This is My code
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
I'm Using Excel 2010 VBA
anybody help me.......
No comments:
Post a Comment