打开电子邮件时运行宏的规则 [英] Rule that runs macro when an email is opened
本文介绍了打开电子邮件时运行宏的规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个宏,可以对打开的邮件执行某些操作.我想创建一个规则,当我打开邮件时会自动执行.
I have created a macro, that does certain things, to an opened mail. I would like to create a rule, that does it automatically, when I open the mail.
我不想一直运行此规则,只是在我打开邮件时,我不想在收到的每封邮件上都强制执行此规则.
I don't want this rule to run all time, just when I open a mail, I don't want to force this rule on each mail I receive.
推荐答案
在@ZZA注释之后,
尝试此代码:
Public WithEvents myItem As Outlook.MailItem
Private Sub Application_ItemLoad(ByVal Item As Object)
If Item.Class = olMail Then
Set myItem = Item
End If
End Sub
Private Sub myItem_Open(Cancel As Boolean)
'Your code
End Sub
在ThisOutlookSession中粘贴代码
Paste code in ThisOutlookSession
编辑
为避免'Your code
触发事件,我们需要一个事件禁用器:
To avoid 'Your code
triggering the event we need an event disabler:
Public WithEvents myItem As Outlook.MailItem
Public EventsDisable as Boolean
Private Sub Application_ItemLoad(ByVal Item As Object)
If EventsDisable = True Then Exit Sub
If Item.Class = olMail Then
Set myItem = Item
End If
End Sub
Private Sub myItem_Open(Cancel As Boolean)
EventsDisable=True
'Your code
EventsDisable=False
End Sub
这篇关于打开电子邮件时运行宏的规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文