【问题标题】:How to use vba to position attachment in body of email in outlook?如何使用 vba 在 Outlook 的电子邮件正文中定位附件?
【发布时间】:2015-08-28 16:12:14
【问题描述】:

我正在尝试让我的 vba 代码在 Outlook 中自动显示一封电子邮件。我无法使附件在邮件正文中显示为图标(图 1)。我可以毫不费力地将其显示在主题行下(图 2)。

 With OutMail
    .To = MailList
    .CC = ""
    .BCC = ""
    .Subject = "Teddy Bear Test"
    .HTMLBody = "<p style='font-family:Arial;font-size:13'> Hello Team: <br><br> Thank You<br><br>"
    .Attachments.Add teddybear.xlsx, , 999
    .Display
End With

我需要做什么来修复我的代码?

【问题讨论】:

标签: vba excel


【解决方案1】:

像这样改变格式。

Option Explicit

Sub AttachmentInBody()

Dim OutMail As MailItem

Set OutMail = Application.CreateItem(0)

With OutMail

    .To = "MailList"
    .CC = ""
    .BCC = ""
    .Subject = "Teddy Bear Test"

    .Display

    If .BodyFormat <> olFormatRichText Then .BodyFormat = olFormatRichText

    .body = "Hello Team:" & vbCr & vbCr & "Thank You" & vbCr

    .Attachments.Add teddybear.xlsx, , 999

End With

Set OutMail = Nothing

End Sub

【讨论】:

    猜你喜欢
    • 2014-01-19
    • 2011-08-24
    • 2021-09-30
    • 1970-01-01
    • 2017-10-23
    • 1970-01-01
    • 2020-08-15
    • 1970-01-01
    • 2015-05-29
    相关资源
    最近更新 更多