0
我正在尝试设置一个VB代码,可以根据表1中列“L”中给出的特定电子邮件地址发送电子邮件。我面临的挑战是添加“.CC”一行。我想要的'抄送'列表的'电子邮件'地址可用在耻辱excel表“Sheet01”的列M用于发送电子邮件的Excel VB代码:将电子邮件添加到CC
有人可以建议适当的编码将电子邮件拉到CC线吗?
注意:CC列表(列M)的长度不是静态的或不同的。
谢谢
Sub CDO_Personalized_Mail_Body()
Dim iMsg As Object
Dim iConf As Object
Dim cell As Range
Dim Flds As Variant
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "[email protected]"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Update
End With
For Each cell In Sheets("Sheet1").Columns("L").Cells
If cell.Value Like "?*@?*.?*" Then
Set iMsg = CreateObject("CDO.Message")
With iMsg
Set .Configuration = iConf
.To = cell.Value
.From = """Test User"" <[email protected]>"
.CC = Sheets("Sheet1").Columns("M").Cells ' **here i want Insert CC line Email ID**
.Subject = "***Important - Email Alert***"
.TextBody = "Hi " & vbNewLine & vbNewLine & _
"This is Auto genrated email " & cell.Offset(0, 2).Value & vbNewLine & vbNewLine & _
"Thank You"
.Send
End With
Set iMsg = Nothing
End If
Next cell
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
末次
谢谢你的回复@ Andre451 ..我会测试这个并让你知道 – Tayyab