在带有VBA的Outlook中嵌入图像

问题描述 投票:1回答:1

以下代码不起作用。它嵌入了照片,但未显示,因为“该文件可能已被移动,重命名或删除。请验证链接指向正确的文件和位置。”

我知道文件路径是正确的,因为我已经进行了三重检查。换个新的眼睛可能会有帮助。

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 = "[email protected]"
    .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
excel vba outlook outlook-vba
1个回答
1
投票

JPG文件名更改为一个单词示例WF_Communications.jpgWFCommunications.jpg

.Attachments.Add "C:\Users\JoeSchmo\Pictures\WF_Communications.jpg", olByValue, 0
.HTMLBody = "<BODY><IMG src=""cid:WF_Communications.jpg"" width=200> </BODY>"
© www.soinside.com 2019 - 2024. All rights reserved.