识别MS Excel或MS Access附件并警告检查内容 [英] Identify MS Excel or MS Access attachments and warn to check contents

查看:155
本文介绍了识别MS Excel或MS Access附件并警告检查内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

个人识别信息(PII)通常是通过非加密电子邮件无意间传输的.大多数情况下,这些数据存储在Excel或Access电子表格中.

Personal identifying information (PII) is often inadvertently transmitted through non-encrypted emails. Most of the times these data are stored in Excel or Access spreadsheets.

点击发送"后,我想识别Access或Excel附件,并询问此电子邮件中有Access或Excel文件,您确定其中不包含PII吗?"

I'd like to identify Access or Excel attachments after hitting send and ask "There are Access or Excel files attached to this email, are you sure these do not contain PII?"

我不知道在附件名称中标识"xlsx"或"accdb"的条件.

The criteria for identifying "xlsx" or "accdb" in the attachment name I just don't get.

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

If Right([attachment_Name],4) = xlsx then

    answer = MsgBox("There are Access or Excel files attached to this email, are you sure these do not contain PHI?",vbYesNo)

    If answer = vbNo 
        Cancel = True
    Else

    End If

End If

End Sub

推荐答案

您可以使用FileSystemObject来获取扩展名:

You could use the FileSystemObject to grab the extension:

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

    Dim olAtt As Attachment
    Dim oFSO As Object
    Dim sExt As String
    Dim bSafe As Boolean

    If Item.Attachments.Count > 0 Then
        bSafe = True
        Set oFSO = CreateObject("Scripting.FileSystemObject")
        For Each olAtt In Item.Attachments
            sExt = oFSO.GetExtensionName(olAtt.FileName)
            If sExt Like "xls*" Or sExt Like "accd*" Or sExt = "mdb" Then
                bSafe = False
                Exit For
            End If
        Next olAtt

        If Not bSafe Then
            If MsgBox("This email contains an Access or Excel file." & vbCr & _
                      "Do you wish to continue?", vbCritical + vbYesNo) = vbNo Then
                Cancel = True
            End If
        End If

        Set oFSO = Nothing

    End If
End Sub  

我已经包含了Access,但可以肯定的是默认情况下它不会发送.

I've included for Access, but pretty sure that doesn't send by default.

这篇关于识别MS Excel或MS Access附件并警告检查内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆