用于选择发件人和签名的 VBA 代码 [英] VBA Code to select Sender and Signature

查看:56
本文介绍了用于选择发件人和签名的 VBA 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Excel 中,我使用这样的代码通过 Outlook 开始发送电子邮件:

In Excel I'm using code like this to begin an e-mail message through Outlook:

Set mOutlookApp = GetObject("", "Outlook.application")
Set OutMail = mOutlookApp.CreateItem(0)

With OutMail
    .To = "blahblah@blah.com"
    .Subject = "More BLAH here"
    .HTMLBody = "Message Text" & .HTMLBody ' This preserves the Signature in the message.
    .Display
End With

通常,当我发送(手动)电子邮件时,我可以选择从普通地址以外的地址发送(通过按发件人"按钮).

Normally, when I send a (manual) e-mail, I can choose to send it from an address other than my normal one (by pressing the "From" button).

另外,我可以从我保存的几个签名中选择一个.

Also, I can choose from one of several signatures I have saved.

如何在 VBA 代码中完成这些壮举?

How can I accomplish these feats in VBA code?

推荐答案

设置MailItem.SendUsingAccount属性,调用Display(此时Outlook会插入签名),读取 HTMLBody 属性(它现在将包含签名),将其与您自己的数据合并(注意不能简单地连接 2 个 HTML 字符串),设置 HTMLBody 属性.

Set the MailItem.SendUsingAccount property, call Display (at that point Outlook will insert the signature), read the HTMLBody property (it will now contain the signature), merge it with your own data (note that 2 HTML strings cannot be simply concatenated), set the HTMLBody property.

这篇关于用于选择发件人和签名的 VBA 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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