收件人在Outlook电子邮件中看不到图像

时间:2019-12-30 18:11:45

标签: excel image excel-vba email outlook

在Outlook中发送电子邮件时,无法显示图像。在我的电子邮件发送功能中,我在单词文档的开头添加了一个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

Email before sending with pictures displayed

Email after sending with pictures gone

1 个答案:

答案 0 :(得分:0)

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