首页 文章

有没有办法检测Outlook邮件是否没有附件?

提问于
浏览
0

我一直在寻找解决方案一段时间,需要一些帮助 .

我需要检测有人在没有附件时向我的Outlook帐户发送消息 .

我有一个情况 .

一封电子邮件发送给我主题中有空格文本它有一个附件如果它有一个附件它发送回复1并将消息移动到文件夹A如果它没有附件,它发送回复2.并将消息移入文件夹B.

欢迎任何帮助

非常感谢

1 回答

  • 0

    您可以在VBScript中轻松完成此操作,如下所示:

    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim m As Variant
    Dim strBody As String
    Dim intIn As Long
    Dim intAttachCount As Integer, intStandardAttachCount As Integer
    
    On Error GoTo handleError
    
    'Edit the following line if you have a signature on your email that includes images or other files. Make intStandardAttachCount equal the number of files in your signature.
    intStandardAttachCount = 0
    
    strBody = LCase(Item.Body)
    
    intIn = InStr(1, strBody, "original message")
    
    If intIn = 0 Then intIn = Len(strBody)
    
    intIn = InStr(1, Left(strBody, intIn), "attach")
    
    intAttachCount = Item.Attachments.Count
    
    If intIn > 0 And intAttachCount <= intStandardAttachCount Then
    
        m = MsgBox("It appears that you mean to send an attachment," & vbCrLf & "but there is no attachment to this message." & vbCrLf & vbCrLf & "Do you still want to send?", vbQuestion + vbYesNo + vbMsgBoxSetForeground)
    
        If m = vbNo Then Cancel = True
    
    End If
    
    handleError:
    
    If Err.Number <> 0 Then
        MsgBox "Outlook Attachment Reminder Error: " & Err.Description, vbExclamation, "Outlook Attachment Reminder Error"
    End If
    
    End Sub
    

    这可以根据您的确切需要进行修改,但它非常简单 .

    简单的谷歌搜索 . 给编写它的人credit .

相关问题