countryfan_nt
Well-known Member
- Joined
- May 19, 2004
- Messages
- 758
Hello friends, Hope all is well! Please help me make the code below work.
Trying to send Outlook mail via VBA, I wish to have the image appear in the body of the message. the image reads value from cell E1 of sheet db.
The draft doesn't show the image of which does exist in C drive.
Thank you very much in advance!
Trying to send Outlook mail via VBA, I wish to have the image appear in the body of the message. the image reads value from cell E1 of sheet db.
The draft doesn't show the image of which does exist in C drive.
Thank you very much in advance!
VBA Code:
Sub SENDMAIL()
Dim rng As Range
' Only send the visible cells in the selection.
LR = Sheets("db").Range("H1").Value
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
FLOW = "C:\Users\nancy.taner\Downloads\avs\ssare\" & Worksheets("db").Range("E1").Value & ".png"
On Error Resume Next
With OutMail
.To = ToAddress
.CC = ccAddress
.BCC = ""
.Subject = "Thank you"
.Attachments.Add FLOW, 1, 0
'You can add other files also like this
'.Attachments.Add (ActiveWorkbook.FullName)
.Display 'or use .Display
On Error GoTo 0
' Try to send
On Error Resume Next
'Set .SendUsingAccount = OutApp.Session.Accounts.Item("ms@drb.com")
Set OutMail = Nothing
Set OutApp = Nothing
strBody = ""
'Then we add an html <img src=''> link to this image
'Note than you can customize width and height - not mandatory
.HTMLBody = "<html><p></p>" & _
"<img src=" & FLOW & "' height=520 width=750>"
End With
End Sub