Chào anh chị GPE,
Anh chị giúp em xem code này, em chèn ảnh trực tiếp vào mail Outlook, nhưng nó không hiển thị ạ, em cám ơn rất nhiều!
Anh chị giúp em xem code này, em chèn ảnh trực tiếp vào mail Outlook, nhưng nó không hiển thị ạ, em cám ơn rất nhiều!
Mã:
Sub SendEmails()
Dim OutApp As Object
Dim OutMail As Object
Dim Body As Worksheet
Dim imgPath As String
Dim img As Object
Dim imgID As String
On Error GoTo ErrorHandler
Set Body = ThisWorkbook.Sheets("Body")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
imgPath = ThisWorkbook.Path & "\pic1.png"
imgID = "pic1"
With OutMail
.To = Body.Range("B1").Value
.Subject = Body.Range("A1").Value
.Attachments.Add imgPath, , 0, imgID
.HTMLBody = "<font face=""Times New Roman"" size=""4"">" & _
"<b>" & Body.Range("A2").Value & "</b><br>" & _
"<img src=""cid:" & imgID & """><br>" & _
"</font>"
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Exit Sub
ErrorHandler:
MsgBox "Có lỗi xảy ra: " & Err.Description, vbCritical, "Lỗi"
End Sub