Outlook 2016附件提醒的我的代码不';t显示正确的对话框
当我使用此代码时:Outlook 2016附件提醒的我的代码不';t显示正确的对话框,outlook,attachment,script,Outlook,Attachment,Script,当我使用此代码时: Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim retMB As Variant Dim strBody As String Dim iIndex As Long On Error GoTo handleError iIndex = InStr(Item.Body, "attach", "attachment") If iI
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim retMB As Variant
Dim strBody As String
Dim iIndex As Long
On Error GoTo handleError
iIndex = InStr(Item.Body, "attach", "attachment")
If iIndex > 0 And Item.Attachments.Count = 1 Then
retMB = MsgBox("Forgot attachment?" & vbCrLf & vbCrLf & "Continue?", vbQuestion + vbYesNo + vbDefaultButton2 + vbMsgBoxSetForeground)
If retMB = vbNo Then Cancel = True
End If
handleError:
If Err.Number <> 0 Then
MsgBox "Sending with no attachments!" & Err.Description, vbExclamation, "ERROR!!!"
End If
End Sub
私有子应用程序\u ItemSend(ByVal项作为对象,取消作为布尔值)
Dim-retMB作为变体
像弦一样暗的链子
尺寸索引与长度相同
关于错误转到handleError
iIndex=仪表(项目主体,“附件”、“附件”)
如果iIndex>0且Item.Attachments.Count=1,则
retMB=MsgBox(“忘记附件?”&vbCrLf&vbCrLf&“继续?”,vbQuestion+vbYesNo+vbDefaultButton2+vbMsgBoxSetForeground)
如果retMB=vbNo,则Cancel=True
如果结束
手柄错误:
如果错误号为0,则
MsgBox“不带附件发送!”&错误描述,VBEQUOTE,“错误!!!”
如果结束
端接头
我想获得带有消息的“忘记附件”对话框。除了我只会看到“不带附件发送!”对话框。当电子邮件没有附件时,为什么不显示提醒对话框?您的支票必须是
Item.Attachments.Count=0
谢谢您的回答。我试过了。我更改为1,因为已经有1个附件(我的签名)。请删除On Error GoTo
语句,以确定哪些行引发了异常/您是否尝试通过在调试器下逐行运行代码来调试代码?只需尝试在ItemSend
事件处理程序的开始行上设置一个断点。通常,在完美的测试项运行之前,不要放入错误处理程序。删除错误时的转到handleError
查看错误。错误处理似乎没有必要。考虑删除所有相关的代码。谢谢大家。我删除了错误转到时的和所有相关代码,该框已经出现,但我必须将iIndex=InStr(Item.Body,“attach”,“attachment”)
编辑为iIndex=InStr(Item.Body,“attach”)
,它可以工作。有没有办法将列表添加到iIndex=InStr(Item.Body,“attach”)
?非常感谢。“附件”应该找到“附件”,这样您的新代码就足够了。如果您想使用“附件”