Embedding Image in Outlook with VBA

北城余情 提交于 2020-02-25 04:09:32

问题


The below code isn't working. It 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 since I've tripled check. A fresh set of eyes could help.

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

回答1:


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>"


来源:https://stackoverflow.com/questions/38905847/embedding-image-in-outlook-with-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!