I am trying to create email draft using excel data and add recipient into BCC, I am able to create Draft using below code but however if am trying to send email from Outlook draft folder I am getting an error as operation failed.
I am not sure if outlook format is not correct or any process I am missing.
Sub SendMultipleEmails()
Dim Mail_Object, OutApp As Object
Dim ws As Worksheet:
Dim arr() As Variant
Dim Pth As String
Dim file_name As String
Dim Month As String
Sheets("Report").UsedRange.ClearContents
Month = Sheets("Macro").Range("C5")
file_name = Sheets("Macro").Range("C4")
Pth = Sheets("Macro").Range("C3").Value
Sheets("Data").Select
Set ws = ActiveSheet
LastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
ws.Sort.SortFields.Clear
ws.Sort.SortFields.Add Key:=ws.Range("I2:I" & LastRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ws.Sort
.SetRange ws.UsedRange
.Header = False
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
arr = ws.Range("I2:I" & LastRow)
Set Mail_Object = CreateObject("Outlook.Application")
first = 2
For i = LBound(arr) To UBound(arr)
If i = UBound(arr) Then GoTo YO
If arr(i + 1, 1) = arr(i, 1) Then
first = WorksheetFunction.Min(first, i + 1)
Else
YO:
Set OutApp = Mail_Object.CreateItem(0)
With OutApp
.Subject = "My Acc Holding Holding")
.Body = "Hello" & vbNewLine _
& vbNewLine _
& "Please find the attached Acc Holding"
.Display
bc = ws.Range("F" & i + 1).Value
For j = first To i
bc = bc & ";" & ws.Range("F" & j).Value
Next
.BCC = bc
first = i + 2
.Save
first = i + 2
End With
End If
Next
End Sub