Outlook 365 - 过程声明与具有相同名称

时间:2018-04-20 06:54:08

标签: outlook

任何人都可以告诉我吗?

我想在Outlook中发送邮件时设置一个问题。我使用这段代码:

 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

不幸的是,我仍然收到此错误消息:

程序声明与具有相同名称的事件或程序的描述不匹配

我将整个代码放在" ThisOutlookSession"部分。我究竟做错了什么?请帮忙。谢谢。

2 个答案:

答案 0 :(得分:0)

cmd参数必须为Cancel

答案 1 :(得分:0)

正确使用:

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

: - )