简体   繁体   中英

Add a “CC recipient” to Outlook 2010 VBA

Can someone please show me how to add a "Cc recipient" to this code? The "To Recipient" and code all work as intended. Thank you for your time.

Sub ForwardEmail(item As Outlook.MailItem)
' Dim oExplorer As Outlook.Explorer
Dim oMail As MailItem
' Set oExplorer = Application.ActiveExplorer

On Error GoTo Release

' If oExplorer.Selection.item(1).Class = olMail Then

Set oMail = item.Forward
oMail.Subject = oMail.Subject
oMail.HTMLBody = "Have a nice day." & vbCrLf & oMail.HTMLBody
oMail.Recipients.Add "email address here"

' oMail.Save
oMail.Send

' End If

Release:
Set oMail = Nothing
' Set oExplorer = Nothing
End Sub
set oRecip = oMail.Recipients.Add("email address here")
oRecip.Type = olCC

or

oMail.CC = "email address here"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM