如何将邮件ID附加到BCC [英] How to attach mail Id's to BCC
本文介绍了如何将邮件ID附加到BCC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的桌子上有150个联系人,我需要一次邮寄所有这些联系人的附件,因此我想在 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
我正在使用Excel 2010 VBA
任何人帮助我.......
I'm Using Excel 2010 VBA
anybody help me.......
推荐答案
这将完成工作
loop arround
olMail.BCC.Add(新邮件地址(email@addes.com));
this will do the work
loop arround
olMail.BCC.Add(New MailAddress("email@addes.com"));
这篇关于如何将邮件ID附加到BCC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文