繁体   English   中英

如何使用vba在Outlook中的电子邮件正文中放置附件?

[英]How to use vba to position attachment in body of email in outlook?

我正在尝试让我的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

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

在此处输入图片说明

在此处输入图片说明

像这样更改格式。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM