在 Outlook VBA 中发送后如何保留对邮件的引用? [英] How to keep reference to mail after sending in Outlook VBA?

查看:93
本文介绍了在 Outlook VBA 中发送后如何保留对邮件的引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Outlook 发送电子邮件(来自 Excel VBA)

I'm using outlook to send e-mails (from Excel VBA)

With OutlookApplication.CreateItem(olMailItem)
  .Subject = topic
  .to = emailAddress
  .HTMLBody = content
  .Send
  msgbox .Sent
end with

msgbox .Sent 引发错误.看起来对邮件的引用在发送后就死了.发送邮件后有没有办法检查.sent或.sentOn参数?

msgbox .Sent raises error. It looks like reference to mail dies after sending. Is there any way to check .sent or .sentOn parameters after sending mail?

推荐答案

Sent 属性可以在项目添加到 Sent Items 文件夹时被检查(即发送).您可以连接到 Sent Items 文件夹的 ItemAdd 事件并检查那里的 Sent 属性.

The Sent property can be checked when an item is added to the Sent Items folder (i.e. sent). You can hook up to the ItemAdd event of the Sent Items folder and check the Sent property there.

请注意,当您尝试自动执行 Outlook 时,Send 方法可能会引发异常.在这种情况下,您很可能面临 Outlook 安全问题.如果您尝试访问任何受保护的属性或方法,它也可以是 Outlook 发出的提示.但在你的情况下,这是一个例外.您会收到安全提示/例外,因为 Outlook 是通过以下方式之一在客户端计算机上配置的:

Note, the Send method may fire an exception when you try to automate Outlook. In this case most probably you are faced with an Outlook security issue. It can also be a prompt issued by Outlook if you try to access any protected property or method. But in your case that is an exception. You get the security prompts/exceptions because Outlook is configured on the client computer in one of the following ways:

  • 使用默认的 Outlook 安全设置(即未设置组策略)
  • 使用由组策略定义的安全设置,但没有应用程序化访问策略
  • 使用由组策略定义的安全设置,该设置在防病毒软件处于非活动状态或过期时发出警告

如果系统上安装了任何最新的防病毒软件,您可以创建一个组策略来防止显示安全提示,或者只是关闭这些警告(这不是真正推荐的).

You can create a group policy to prevent security prompts from displaying if any up-to-date antivirus software is installed on the system or just turn these warning off (which is not really recommended).

Outlook 对象模型的安全行为 文章.

此外,您还可以考虑使用构建 Outlook 且不会产生安全问题的低级代码 - 扩展 MAPI.考虑围绕该 API 使用任何第三方包装器,例如 Redemption.

Also you may consider using a low-level code on which Outlook is built and which doesn't give security issues - Extended MAPI. Consider using any third-party wrappers around that API such as Redemption.

另一种选择是 Outlook 安全管理器允许在运行时即时抑制 Outlook 安全问题.

Another option would be the Outlook Security Manager which allows suppressing Outlook security issues at runtime on the fly.

这篇关于在 Outlook VBA 中发送后如何保留对邮件的引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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