Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
989 views
in Technique[技术] by (71.8m points)

excel - Embedding Image in Outlook with VBA

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") & "MicrosoftSignaturesAmir 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:UsersJoeSchmoPicturesWF 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

.Attachments.Add "C:UsersJoeSchmoPicturesWF_Communications.jpg", olByValue, 0
.HTMLBody = "<BODY><IMG src=""cid:WF_Communications.jpg"" width=200> </BODY>"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...