在Outlook邮件中添加多个CC

我有这一行代码,我试图在Outlook邮件中添加多个CC。 但它只是返回; 。 我在MSDN上find了这个示例。

 Dim ccMail as String Dim ccRow as Long Dim objMail as Object ccRow = Cells(Rows.count, 16).End(xlUp).Row With objMail .Subject = Sheet1.TextBox1.Value For k = 4 To ccRow ccMail = ccMail & ";" & Cells(k, 1).Value Next k .cc = ccMail end with 

所有的CC收件人都可以在P列中find任何帮助?谢谢。

您使用了With objMail但没有为Cells(k, 1).Value指定工作表。 这很可能会导致错误。

此外,我认为你想引用ws.Cells(k, 16)因为你想要的是列P

这里是一个关于如何循环使用Do-Until循环来获取单元格值的示例。

 Option Explicit Sub Example() Dim olApp As Object Dim olMail As Object Dim olRecip As Object Dim iRow As Long Dim Recip As String Dim Sht As Worksheet iRow = 2 Set olApp = CreateObject("Outlook.Application") Set olMail = olApp.CreateItem(0) Set Sht = ActiveWorkbook.Sheets("Sheet1") With Sht With olMail Do Until IsEmpty(Cells(iRow, 16)) Recip = Cells(iRow, 16).Value Set olRecip = .Recipients.Add(Recip) olRecip.Type olCC olRecip.Resolve iRow = iRow + 1 Loop .Subject = "Subject" .Body = "Hi " & .Body .Display End With End With Set olApp = Nothing End Sub 

Do-Until循环和IsEmpty