PrakashGunabalan
New Member
- Joined
- Oct 26, 2024
- Messages
- 5
- Office Version
- Prefer Not To Say
- Platform
- Windows
Option Explicit
VBA Code:
Sub Filter_Data_and_Send_Email()
Dim rg As Range, i As Long
Dim fltr As Range, oDoc As Object
Set rg = Sheet1.Cells(1, 1).CurrentRegion
Set fltr = Sheet2.Cells(1, 1).CurrentRegion
For i = 2 To rg.Rows.Count
fltr.AutoFilter 1, rg(i, 1).Value2
With CreateObject("Outlook.Application").CreateItem(0)
.Display
.To = rg(i, 2).Value2
.Subject = "Report"
Set oDoc = .GetInspector.WordEditor
With oDoc.Range
.insertParagraphAfter
.InsertAfter "Thank you,"
.insertParagraphAfter
.InsertAfter "Greg"
End With
fltr.SpecialCells(xlCellTypeVisible).Copy
oDoc.Range(0, 0).Paste
.HTMLBody = "" & _
"Whoa that it " & .HTMLBody
.HTMLBody = "" & _
"Please see table below" & .HTMLBody
.HTMLBody = "" & _
"Hi Team, " & .HTMLBody
'.Send
End With
Next i
End Sub
Last edited by a moderator: