如何使用vba在Outlook中将附件放置在电子邮件正文中? [英] How to use vba to position attachment in body of email in outlook?

查看:282
本文介绍了如何使用vba在Outlook中将附件放置在电子邮件正文中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to have my vba code automatically display an e-mail in outlook. I am having trouble making the attachment appear as an icon in the body of the message (pic 1). I have no trouble making it show up under the subject line (pic 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

我该怎么做才能修复我的代码?

What do I need to do to fix my code?

推荐答案

更改格式.

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

这篇关于如何使用vba在Outlook中将附件放置在电子邮件正文中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆