RKVALU
RKVALU

Reputation: 25

How to add address to .CC field?

I have working code where I would like to add CC field with preexisting email id's.

Tried all ways around, but not able to crack the code

Sub Reply_Scripting()

    Dim origEmail As MailItem

    Dim replyEmail As MailItem

    Dim oRespond As Outlook.MailItem

    Set origEmail = Application.ActiveWindow.Selection.Item(1)

    Set replyEmail = Application.CreateItemFromTemplate("C:\Users\Test.oft")

    replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody

    replyEmail.Display

End Sub

Upvotes: 2

Views: 113

Answers (2)

0m3r
0m3r

Reputation: 12499

Simply add

replyEmail.CC = "[email protected]"

Example

Sub Reply_Scripting()
    Dim origEmail As MailItem
    Dim replyEmail As MailItem
    Dim oRespond As Outlook.MailItem

    Set origEmail = Application.ActiveWindow.Selection.Item(1)
    Set replyEmail = Application.CreateItemFromTemplate("C:\Users\Test.oft")

    replyEmail.CC = "[email protected]"

    replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.reply.HTMLBody
    replyEmail.display

End Sub

Upvotes: 1

cyboashu
cyboashu

Reputation: 10433

It's same as what you did for your body.

Sub Reply_Scripting()
Dim origEmail As MailItem

Dim replyEmail As MailItem

Dim oRespond As Outlook.MailItem

Set origEmail = Application.ActiveWindow.Selection.Item(1)

Set replyEmail = Application.CreateItemFromTemplate("C:\Users\ashu\Desktop\test.oft")

'/ Add new CC addresses along with existing addresses.
replyEmail.CC = origEmail.CC & ";" & "[email protected];[email protected]"


replyEmail.BodyFormat = olFormatHTML
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody

replyEmail.Display

End Sub

Upvotes: 1

Related Questions