Consulting

Results 1 to 2 of 2

Thread: Outlook Attachment Search

  1. #1
    VBAX Newbie
    Joined
    Jul 2015
    Posts
    1
    Location

    Red face Outlook Attachment Search

    Hello!

    I am trying to create a macro that after a user hits send message, the macro searches the attachments (Excel, Word, PDF). If it finds what it is looking for, a message box pops up warning the user. The user can choose to send anyway or cancel. If nothing is found the email is sent.

    So I've decided to use this to start off:
    Public Sub Application_ItemSend(ByVal item As Object, Cancel As Boolean)
    This is the message box part which works great. Gives the message box and allows the user to proceed. The Search is the result from the cycling (below).
    If Search = True Then
    If MsgBox(msg, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Attachment Check") = vbNo Then
            Cancel = True
    End If
    The part I'm struggling with is cycling through each attachment and then calling the respective search sub based on its file type.
    Is there a way to do this without saving all the attachments to a temporary folder or is that the only way?
    What I would like to be able to do is the following:

    For each attachment
     If the file type is:
    Excel, call SearchExcel
    Word, call SearchWord
    Pdf call SearchPdf 
    End If
    Loop
    Thanks!!!

  2. #2
    You are not going to be able to do the searches without saving the attachments to a temporary location and opening them in suitable applications. This is going to impose a large overhead on the sending of any message that has attachments, and I have to wonder what the point is? Couldn't you check the content of the attachments before you attach them?
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •