1

The below code embeds the photo but doesn't display because

"The file may have been moved, renamed, or deleted. Verify that the link points to the correct file and location."

I know the file path is correct.

Sub mail()

Dim Sig As String

Set myOlApp = CreateObject("Outlook.Application")

LR400 = Columns(1).Find("*", SearchDirection:=xlPrevious).Row

sPath = Environ("appdata") & "\Microsoft\Signatures\Amir Higgs.txt"

For x = 2 To LR400

    If Cells(x, 2) <> "no email" Then

     emails = Cells(x, 1)
    'TheBody1 = "The Parallon Workforce Team" & vbCrLf & vbCrLf & vbCrLf & _
    "Amir Higgs" & vbCrLf & _
    "Accounts Payable Clerk" & vbCrLf & _
    "Parallon Workforce Solutions" & vbCrLf & _
    "1000 Sawgrass Corporate Pkwy, 6th Floor" & vbCrLf & _
    "Sunrise, FL 33323" & vbCrLf & _
    "P:  954-514-1656" & vbCrLf & _
    "www.parallon.com"

    Set myitem = myOlApp.CreateItem(olMailItem)

    With myitem
        .SentOnBehalfOfName = "PARA.WFAdjustments@Parallon.com"
        .To = Cells(x, 2)
        .Subject = Cells(x, 3)
        .Body = TheBody1
        '.CC = ""
        .Attachments.Add emails
        .Attachments.Add "C:\Users\JoeSchmo\Pictures\WF Communications.jpg", olByValue, 0
        .HTMLBody = "<BODY><IMG src=""cid:WF Communications.jpg"" width=200> </BODY>"

        .display

    End With

End If

Next x

Set OutMail = Nothing
Set OutApp = Nothing

End Sub
Community
  • 1
  • 1
KnowMeNot
  • 47
  • 1
  • 1
  • 7
  • I got this to work a couple years ago by following this advice: [Excel-VBA : Send Mail with Embedded Image in message body From MS Outlook using Excel](http://excel-macro.tutorialhorizon.com/excel-vba-send-mail-with-embedded-image-in-message-body-from-ms-outlook-using-excel/) – PeterT Aug 11 '16 at 20:54
  • I have already used that link as a reference for the majority of this code. @PeterT – KnowMeNot Aug 11 '16 at 21:01
  • @KnowMeNot did you notice that the link uses 'single quotes' to wrap the src property? Also, have you tried with an image name that doesn't contain a space (just in case the string isn't getting wrapped correctly and the HTML is looking for an image named "WF") – Mikegrann Aug 11 '16 at 21:23
  • Try to repl `" "` for this `" "` – Sgdva Aug 11 '16 at 21:31

1 Answers1

3

Change your JPG file name to one word Example WF_Communications.jpg or WFCommunications.jpg

.Attachments.Add "C:\Users\JoeSchmo\Pictures\WF_Communications.jpg", olByValue, 0
.HTMLBody = "<BODY><IMG src=""cid:WF_Communications.jpg"" width=200> </BODY>"
0m3r
  • 12,286
  • 15
  • 35
  • 71