Warning When I'M Sending A Important File In Outlook

Discussion in 'Computer Software' started by Aalina, May 17, 2017.

  1. Aalina

    Aalina New Member

    Joined:
    May 17, 2017
    Messages:
    1
    Trophy Points:
    1
    Ratings:
    +0 / 0 / -0
    hi,

    I have a important file which contains some confidential information. Usually I will not send it to others. But I want to make sure I will not do that by mistake. So if I can get a waring when I'm sending a important file in Outlook, I can recheck it and make sure I'm not do that by mistake. Is there any fuction in outlook can do that? I can't find it out.

    Best regards.
     

  2. Rerthgy

    Rerthgy New Member

    Joined:
    Saturday
    Messages:
    1
    Trophy Points:
    1
    Ratings:
    +0 / 0 / -0
    There is no such focution in outlook as I know. I can only find a way using VBA mcro to do that. And here is the code, you can try it:

    Code:
    Public WithEvents objInspectors As Outlook.Inspectors
    Public WithEvents objMail As Outlook.MailItem
    
    Private Sub Application_Startup()
        Set objInspectors = Outlook.Application.Inspectors
    End Sub
    
    Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
        If Inspector.CurrentItem.Class = olMail Then
           Set objMail = Inspector.CurrentItem
        End If
    End Sub
    
    Private Sub objMail_AttachmentAdd(ByVal Attachment As Attachment)
        Dim strFile As String
        Dim objFileSystem As Object
        Dim strFilePath As String
        Dim objWordApp As Word.Application
        Dim objWordDocument As Word.Document
        Dim objSentence As Object
        Dim objWord As Object
        Dim strMsg As String
        Dim nResponse As Integer
        strFile = Attachment.DisplayName
        'Here we take Word document and text file as an example
        If InStr(LCase(strFile), "docx") > 0 Or InStr(LCase(strFile), "doc") > 0 Or InStr(LCase(strFile), "txt") > 0 Then
           Set objFileSystem = CreateObject("Scripting.FileSystemObject")
           strFilePath = objFileSystem.GetSpecialFolder(2).Path & "\" & Format(Now, "dd-mm-yyyy-hh-mm-ss") & Attachment.DisplayName
           Attachment.SaveAsFile strFilePath
           Set objWordApp = CreateObject("Word.Application")
           Set objWordDocument = objWordApp.Documents.Open(strFilePath)
           objWordDocument.Activate
           For Each objSentence In objWordDocument.StoryRanges
               For Each objWord In objSentence.Words
                   'Check if contain specific words
                   'You can change the following line as per your actual needs
                   If objWord.Text = "DataNumen" Or objWord.Text = "Confidential" Then
                      strMsg = "The new attachment " & Chr(34) & Attachment.DisplayName & Chr(34) & " may contain confidential information. Are you sure to attach it?"
                      nResponse = MsgBox(strMsg, vbExclamation + vbYesNo, "Check Confidential File")
                      If nResponse = vbNo Then
                         Attachment.Delete
                      End If
                   End If
                   Exit For
              Next
           Next
        End If
    End Sub
    I also attach the link I find,

    https://www.datanumen.com/blogs/get-warning-attaching-confidential-files-outlook-email/

    Hope it helps.
     

Share This Page...