1

我想在 Outlook 2010 中创建一个 VBA 脚本,当用户按下发送按钮时,会出现一个对话框并询问他们一个问题,答案是“是或否”。如果他们回答“是”,则电子邮件会正常发送,但如果回答“否”,则不会发送电子邮件,他们将被带回电子邮件中进行任何更改。

我现在有一个正在使用的脚本(借用:)),见下文,但它只给了我一个确定按钮,即使我点击了红十字,它仍然会发送电子邮件 - 任何帮助将不胜感激

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
EmailSend = MsgBox("Is Your Recipient Correct?")
End Sub

提前致谢

4

1 回答 1

0

In the "ThisOutlookSession" module, you can use something like this:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If MsgBox("Yes or no?", vbYesNo) = vbNo Then Cancel = True
End Sub

It prompts with a "Yes/No" message box (because of the vbYesNo argument) and then you provide a True boolean value to "Cancel" based on the response to the dialog. Also, at least on Windows 7, the red "x" is disabled when using the yes/no prompt. But if not, then I would do something like this:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Cancel = True
    If MsgBox("Yes or no?", vbYesNo) = vbNo Then Cancel = True Else Cancel = False
End Sub

Thus, it always cancels unless they say "Yes" specifically.

于 2013-10-09T13:41:09.930 回答