Excel 如何设置抄送收件人?
单元格A1和A2中的电子邮件地址都显示在Outlook的“收件人”中 如何将单元格A2设置为“cc” 输入和输出:Excel 如何设置抄送收件人?,excel,vba,outlook,Excel,Vba,Outlook,单元格A1和A2中的电子邮件地址都显示在Outlook的“收件人”中 如何将单元格A2设置为“cc” 输入和输出: 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 S
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
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
您没有正确设置收件人类型:
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
可能重复的