如何在使用宏在 Outlook 中发送邮件之前检查详细信息? [英] how to check details before sending mails in outlook using macros?

查看:80
本文介绍了如何在使用宏在 Outlook 中发送邮件之前检查详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须向许多不同的组发送邮件,有时我发送到错误的组.

I have to send mails to many different groups and sometimes I send to the wrong group.

我想创建 VBA 代码来检查主题标题的前两个字母以及邮件正文中是否存在相同的两个首字母,因为我发送邮件.如果升级正确,则应发送邮件,否则代码应显示一些错误消息.

I want to create VBA code to check, the initial two letters of subject header and also whether the same two initial letters are present in the mail body, as I send the mail. If the escalation is correct then mail should be sent otherwise the code should display some error message.

推荐答案

看起来您需要处理 ItemSend 应用程序类的事件,每当发送 Microsoft Outlook 项目时都会触发该事件,或者由用户通过检查器(在检查器关闭之前,但在用户单击发送"按钮之后)或在程序中使用 Outlook 项目(例如 MailItem)的 Send 方法时.请注意,传递给事件处理程序的 Cancel 参数允许取消操作.如果事件过程将此参数设置为 true,则发送操作未完成且检查器保持打开状态.

It looks like you need to handle the ItemSend event of the Application class which is fired whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Send button) or when the Send method for an Outlook item, such as MailItem, is used in a program. Be aware, the Cancel parameter passed to the event handler allows to cancel the action. If the event procedure sets this argument to true, the send action is not completed and the inspector is left open.

Public WithEvents myOlApp As Outlook.Application  
Public Sub Initialize_handler()    
   Set myOlApp = Outlook.Application  
End Sub 

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)  
  Dim prompt As String  
  prompt = "Are you sure you want to send " & Item.Subject & "?"  
  If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then  
    Cancel = True  
  End If  
End Sub

在代码中,您可以查看您需要的任何内容 - 主题、正文或 HTMLBody 值.

In the code you can check out whatever you need - the Subject, Body or HTMLBody values.

这篇关于如何在使用宏在 Outlook 中发送邮件之前检查详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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