Dear Team,
I created code for sending mail based on value matched. I want to insert the data to the mail body in table format from the sheet.
In column BP if it is in service then the contents to be copied from columns C, I & BQ
and the body format is
Dear Service Team,
Please take care of the below list,
Customer Name | Office address | Support required |
M/S ACC Ltd | Magadi Road | The customer has requested to share the Spares catalogue/Electrical Drawing of the M1CR batching plant. |
M/s Vavedha Infra | office address | support required |
M/s Ramalingm Construction | office address | support required |
M/s ZIRCON RMC | Bangalore | The customer has requested to share the Spares catalogue/Electrical Drawing of the M1CR batching plant. |
and another mail to be triggered for the Spares team
Dear Spares Team,
Please take care of the below list,
Customer Name | Office address | Support required |
M/s Panchami Concrete | office address | support required |
M/s HI Tech RMC | office address | support required |
M/s CCCL Infra | office address | support required |
And also another mail to be triggered for Units Team
Dear Units Team,
Please take care of the below list,
Customer Name | Office address | Support required |
M/S Shree Concrete | Magadi Road | The customer has requested to share the Spares catalogue/Electrical Drawing of the M1CR batching plant. |
M/s Tulasi concrete | office address | support required |
My code is
Code
Sub Grievances_Mail()
Dim olApp As Object
Dim olMail As Object
Dim olInsp As Object
Dim wdDoc As Object
Dim oRng As Object
Dim sPath As String
Dim sMessage As String
Dim sFile As String
Dim cell As Range
Dim sBCC As String
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Weekly Visit report")
For Each cell In sh.Columns("BP").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "Service" Then
sMessage = "<br>" & "<font size=""3"" face=""Cambria"" color=""Blue"">" & "Dear Service Team, <br><br>" _
& "Please take care of the below list, <br><br>" _
& cell.Offset(, -65).Value & " " & cell.Offset(, -59).Value & " " & cell.Offset(, 1).Value
End If
Next cell
Set olApp = CreateObject("Outlook.Application")
On Error Resume Next
Set olMail = olApp.CreateItem(0)
With olMail
.BCC = sBCC
.Subject = "GREETINGS FROM SCHWING STETTER!!!"
.HTMLBody = sMessage
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor 'access the message body for editing
.Display 'required to edit message body
End With
Set olApp = Nothing
Set olMail = Nothing
Set olInsp = Nothing
Set wdDoc = Nothing
Set oRng = Nothing
End Sub
Display More
Can anyone help me with how to do the above y requirements? My file is attached here for your kind reference