vbaoutlook收件人

来自单元格A1和A2的电子邮件地址都显示在outlook的“to”上。 但“cc”是空的。

如何将单元格A2设置为“cc”?

input和输出:

单元格A1是我要“发送给”的电子邮件地址。

单元格A2是我想要“抄送”的电子邮件地址。

VBA代码:

Sub Button1_Click() Const olMailItem As Long = 0 Const olTo As Long = 1 Const olCC As Long = 2 Const olBCC As Long = 3 Dim OutApp As Object Dim OutMail As Object Dim myRecipient As Object Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(olMailItem) On Error Resume Next With OutMail .To = OutMail.Recipients.Add(Range("A1")) myRecipient.Type = olTo .CC = OutMail.Recipients.Add(Range("A2")) myRecipient.Type = olCC .BCC = "" .Subject = "This is the Subject line" End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End Sub 

您没有正确设置收件人types:

 With OutMail Set myRecipient = .recipients.Add(Range("A1")) myRecipient.Type = olTo Set myRecipient = .recipients.Add(Range("A2")) myRecipient.Type = olCC .BCC = "" .Subject = "This is the Subject line" End With