Avatar of amol Jadhav
amol Jadhav
 asked on

Want to add CC in mail merge

I am trying to use Mail merge, however i want that CC should be added while sending emails
VBA

Avatar of undefined
Last Comment
Jamie Garroch (MVP)

8/22/2022 - Mon
Rgonzo1971

Hi,

Can we see relevant part of your code?

MailItem.cc = "Email address1; Email address2"

Open in new window

Regards
amol Jadhav

ASKER
Option Explicit

Public Sub TestMail()

Dim newMail         As Outlook.MailItem
Dim toRange         As Range
Dim ccRange         As Range
Dim fName           As Variant

Set toRange = Sheets("Sheet1").Range("A2:A4")       'Change as required
Set ccRange = Sheets("Sheet1").Range("D2:D5")       'Change as required
With Application.FileDialog(msoFileDialogOpen)

    .AllowMultiSelect = False
    .Filters.Clear
    .Filters.Add "PowerPoint Files", "*.pptx"
    .Filters.Add "PowerPoint 97-2003 Files", "*.ppt"
    .Show
   
    Dim i As Integer
    For i = 1 To .SelectedItems.Count
        fName = .SelectedItems(i)
    Next i
   
End With

If fName <> False Then

    Set newMail = Outlook.CreateItem(olMailItem)
   
    With newMail
   
        Dim cell As Range
   
        For Each cell In toRange
            If cell.Value <> "" Then .To = .To & cell.Value & ";"
        Next cell
        .To = Left(.To, Len(.To) - 1)
       
        For Each cell In ccRange
            If cell.Value <> "" Then .CC = .CC & cell.Value & ";"
        Next cell
        .CC = Left(.CC, Len(.CC) - 1)
   
        .Attachments.Add fName, olByValue
        .Send
       
    End With

End If

End Sub
amol Jadhav

ASKER
can u check  d code
Your help has saved me hundreds of hours of internet surfing.
fblack61
Rgonzo1971

the code seems ok
amol Jadhav

ASKER
which code
Rgonzo1971

Yours of course
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Jamie Garroch (MVP)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.