PDA

View Full Version : [SLEEPER:] Outlook Attachment Search



Ryzon9
07-11-2015, 04:03 PM
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!!!

gmayor
07-12-2015, 11:49 PM
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?