首页 > 解决方案 > 收件人无法在 Outlook 电子邮件中看到图像

问题描述

我在 Outlook 中发送电子邮件时无法显示图像。在我的电子邮件发送功能中,我在word文档的开头添加了一个inlineshape图片,一切都显示正常,但是当我发送电子邮件时,inline图片和我签名中的图片都消失了。请参阅下面的屏幕截图和代码。我曾尝试寻找答案但没有成功。

Sub Send_Email( _
            strTo As String, _
            Optional strFromEmail As String, _
            Optional strSubject As String, _
            Optional strCC As String, _
            Optional strBCC As String, _
            Optional BodyFormat As olBodyFormat = olFormatPlain, _
            Optional varBody1 As Variant, _
            Optional strPicturePath As String, _
            Optional lngPicutreSize As Long = 100, _
            Optional varBody2 As Variant, _
            Optional strAttachmentPath As String, _
            Optional blnSendEmail As Boolean = False)

Dim olApp As Outlook.Application
Set olApp = New Outlook.Application

Dim olEmail As Outlook.MailItem
Set olEmail = olApp.CreateItem(olMailItem)

Dim olInsp As Outlook.Inspector
Dim wdDoc As Word.document
Dim shpEmailShape As Word.InlineShape

With olEmail
    .BodyFormat = BodyFormat
    .display
    If strFromEmail <> "" Then
        .SentOnBehalfOfName = strFromEmail
    End If
    .To = strTo
    .Subject = strSubject
    .CC = strCC
    .BCC = strBCC
    If BodyFormat = olFormatHTML Then
        If varBody2 <> "" Then
            .HTMLBody = varBody2 & "<br>" & .HTMLBody
        End If
        If varBody1 <> "" Then
            .HTMLBody = varBody1 & "<br>" & .HTMLBody
        End If
    ElseIf BodyFormat = olFormatRichText Then
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        If IsMissing(varBody2) = False Then
            varBody2.Copy
            wdDoc.Range(0, 0).Paste
        End If
        If strPicturePath <> "" Then
            Set shpEmailShape = wdDoc.Range(0, 0).InlineShapes.AddPicture(strPicturePath)
            shpEmailShape.LockAspectRatio = msoCTrue
            shpEmailShape.Height = lngPicutreSize
        End If
        If IsMissing(varBody1) = False Then
            varBody1.Copy
            wdDoc.Range(0, 0).Paste
        End If
    Else
        On Error Resume Next
        If varBody2 <> "" Then
            .body = varBody2 & vbCrLf & .body
        End If
        On Error GoTo 0
        On Error Resume Next
        If varBody1 <> "" Then
            .body = varBody1 & vbCrLf & .body
        End If
        On Error GoTo 0
    End If
    If strAttachmentPath <> "" Then
        .Attachments.Add strAttachmentPath
    End If
End With

If blnSendEmail = True Then
    olEmail.send
End If

发送前的电子邮件并显示图片

发送后的电子邮件,图片不见了

标签: excelvbaimageemailoutlook

解决方案


听起来您确实是以 RTF 格式发送的。您需要发送带有作为附件添加并由 HTML 正文引用的图像的 HTML 格式的消息。


推荐阅读