countryfan_nt
Well-known Member
- Joined
- May 19, 2004
- Messages
- 765
Hello friends, Hope all is well! Please help me. The code is supposed to insert an image from a folder and place it in the body
of the email / outlook. I am getting a grey box instead.
Please help me fix the below VBA code.
Thank you Very much in advance!
of the email / outlook. I am getting a grey box instead.
Please help me fix the below VBA code.
Thank you Very much in advance!
VBA Code:
Sub SENDMAIL()
Dim rng As Range
Set rngT = Sheets("staff").Range("A1:D1")
' Only send the visible cells in the selection.
Dim pic As String
LR = Sheets("db").Range("H1").Value
Set rng = Sheets("staff").Range("A1:D17118").SpecialCells(xlCellTypeVisible)
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Adjust this according to your table gets the last row in the Sheet named "DB" column "A"
ToAddress = Sheets("DB").Range("f1").Value
pic = "C:\Users\nawaf.altaher\Desktop\Labs\" & Sheets("DB").Range("J1").Value
On Error Resume Next
With OutMail
.To = ToAddress
.CC = ccAddress
.BCC = ""
.Subject = "Medical Insurance Renewal."
.Attachments.Add pic, 1, 0
.HTMLBody = "<html><p></p>" & _
"<img src=""PIC""height=520 width=750>"
.Display
On Error GoTo 0
' Try to send
On Error Resume Next
Set OutMail = Nothing
Set OutApp = Nothing
End With
End Sub