vba代码根据对话框回答发送电子邮件

时间:2018-01-05 03:09:10

标签: vba email outlook outlook-vba outlook-2010

以下是我想要发生的步骤或类似的步骤。如果没有审查特殊说明,我基本上想要一个取消电子邮件的对话框:

  1. 电子邮件标有名为“特殊投放”的类别。这已经在所有事情之前完成了。
  2. 我完成了工作请求并准备发回回复。
  3. 点击“全部回复”
  4. 电子邮件弹出,我可以添加附件和文本正文等...
  5. 当我点击发送时,我想要弹出一个对话框询问“你有没有查看送货说明?”
  6. 如果我点击“确定”,则电子邮件会发送,如果我点击“取消”,则电子邮件会关闭,并且不会发送任何内容。
  7. 这是我现在使用的代码;然而,无论我点击什么,它都会发送电子邮件...任何帮助都会很棒。

    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    
    If Item.Categories = "Special Delivery" And MsgBox("Did you review delivery instructions?", vbOKCancel) <> vbOK Then
    Cancel = True
    End If
    End Sub
    

2 个答案:

答案 0 :(得分:0)

取出Item.Categories,因为Item在您回复并使用vbOKCancel) = vbCancel

时不会有类别

实施例

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim Prompt As String
        Prompt = "Did you review delivery instructions?"

        If MsgBox(Prompt, vbOKCancel) = vbCancel Then
            Cancel = True
        End If
End Sub

答案 1 :(得分:-1)

您可以通过分离它们来确定问题所在。

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

If Item.Categories = "Special Delivery" Then

    debug.print "Item has Special Delivery category"

    If MsgBox("Did you review delivery instructions?", vbOKCancel) <> vbOK Then
        Cancel = True
    End If

Else

    debug.print "If item has Special Delivery category it was not identified"

End If

End Sub
相关问题