如何将 HTML jpeg 附加到电子邮件?

How to attach an HTML jpeg to email?

我利用Excel群发邮件客户端。我的 VBA 代码找不到广告的 HTML jpeg。

是imgurlink不好还是我的代码?

MailWindows()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range

    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo cleanup
    For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
        If cell.Value Like "?*@?*.?*" Then

            Set OutMail = OutApp.CreateItem(0)
    
            On Error Resume Next
            With OutMail
                .To = cell.Value
                .Subject = "insert here"
.Attachments.Add Fname, 1, 0
                .HTMLBody = "<img src=""cid:"https://url.jpeg height=1650 width=1275>"
                .Display  
            End With
            On Error GoTo 0
            Set OutMail = Nothing
        End If
    Next cell

cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
End Sub

除了引用问题,您还通过 cid (content-id) 引用图像,这意味着电子邮件客户端必须在同一封邮件中使用 Content-ID MIME header 设置为 https://url.jpeg.

如果您要引用外部图像,则需要

.HTMLBody = "<img src=""https://url.com/someimage.jpeg"" height=1650 width=1275>"

如果您引用嵌入的图像,您需要实际添加附件并使用 Attachment.PropertyAccessor.SetProperty

适当地设置 PR_ATTACH_CONTENT_ID MAPI 属性