简体   繁体   English

使用 Excel VBA 发送 Email outlook

[英]Send Email outlook using Excel VBA

I am trying to send an email using Excel with this code:我正在尝试使用以下代码使用 Excel 发送 email:

Sub SEND_EMAIL()

Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")

Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)

' ADRESSE
olMail.To = "selojo7915@rippb.com"
' Subject
olMail.subject = "Line"
' BODY
olMail.body = "this"

olMail.Send

When starting this macro i have the following error启动此宏时出现以下错误

在此处输入图像描述

The error is in the last line (olMail.Send)错误在最后一行 (olMail.Send)

And every time i am trying to send an email outlook is starting to update and after a moment it's showing error每次我尝试发送 email outlook 都开始更新,过了一会儿就显示错误

Exception de HRESULT: 0x80004004 (E_ABORT) HRESULT 异常:0x80004004 (E_ABORT)

You see a security issue (earlier prompts) because Outlook is configured on the client computer in one of the following ways:您会看到一个安全问题(较早的提示),因为 Outlook 是通过以下方式之一在客户端计算机上配置的:

  • Uses the default Outlook security settings (that is, no Group Policy set up)使用默认的 Outlook 安全设置(即没有设置组策略)
  • Uses security settings defined by Group Policy but does not have programmatic access policy applied使用由组策略定义的安全设置,但未应用编程访问策略
  • Uses security settings defined by Group Policy which is set to warn when the antivirus software is inactive or out of date使用由组策略定义的安全设置,该设置设置为在防病毒软件处于非活动状态或过时时发出警告

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).您可以创建一个组策略,以防止在系统上安装任何最新的防病毒软件时显示安全提示,或者只是关闭这些警告(不推荐这样做)。

Read more about that in the Security Behavior of the Outlook Object Model article. 在 Outlook Object Model 文章的安全行为中阅读更多相关信息。

You may consider using the following workarounds:您可以考虑使用以下解决方法:

  • Install any antivirus software with latest updates.安装任何具有最新更新的防病毒软件。
  • Use a low-level API - Extended MAPI which doesn't trigger security issues.使用低级 API - 不会触发安全问题的扩展 MAPI。 You may also consider Redemption which is a convenient wrapper around Extended MAPI.您还可以考虑 Redemption,它是一个方便的 Extended MAPI 包装器。
  • Create a COM add-in which has access to the safe Application instance.创建一个 COM 加载项,它可以访问安全的应用程序实例。
  • Use group policy settings to turn such security prompts/issues when dealing with Outlook.在处理 Outlook 时使用组策略设置来关闭此类安全提示/问题。
  • Also you may consider using third-party components that allow turning off and on dynamically security prompts and issues in Outlook. See Outlook Security Manager for more information.您也可以考虑使用第三方组件,允许在 Outlook 中动态关闭和打开安全提示和问题。有关详细信息,请参阅Outlook 安全管理器

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

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