【问题标题】:Item_Send event not firing for Outlook 2010 .oft template未针对 Outlook 2010 .oft 模板触发 Item_Send 事件
【发布时间】:2020-06-25 17:06:17
【问题描述】:

我为 Outlook 邮件消息模板编写了一个非常简单的 Item_Send 处理程序,该模板存储为我通过宏运行的 oft 文件:

Function Item_Send()
    MsgBox "hello"
    Item_Send = False
End Function

此事件未触发:我看不到消息框,消息已发送。

谁能解释为什么会这样以及我该如何解决?

【问题讨论】:

  • 事件的名称是ItemSend。没有空格或下划线。此外,您需要指定参数:该方法应接受项目对象和布尔值。

标签: vba outlook outlook-2010


【解决方案1】:

有一个内置的 ItemSend 可以像这样在“ThisOutlookSession”模块中使用。

Private Sub Application_ItemSend(ByVal Item As Object, _
                                  Cancel As Boolean) 
    If item.subject = "subject of the template" then
        MsgBox "hello"
        Cancel = True 
   End if
End Sub

【讨论】:

  • 这是一个全局事件处理程序。他需要一些特定于他的模板的东西!
  • @Dino If item.subject = "subject of the template" then 或其他识别特征。
  • 所以这里的主题不是电子邮件的主题。模板的名称?无论如何,我通过添加注册表值来为自定义表单启用脚本来解决我的问题。
  • 如果模板具有传递给电子邮件的唯一主题,则表明邮件是使用模板创建的。否则,将需要邮件中模板特有的其他标识符。
猜你喜欢
  • 2012-11-29
  • 2023-03-13
  • 1970-01-01
  • 2014-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-16
  • 1970-01-01
相关资源
最近更新 更多