How do I search email attachments

Status
Not open for further replies.
T

TU0

I would like to be able to search email attachments for a given text string.

Is this possilbe or would it require a macro? If a macro is required, does

anyone have any idea where to start with this as I'm a bit stuck on how to

acheive this.

Regards,

Martin
 
K

Ken Slovak - [MVP - Outlook]

Any text information within an attachment is not available using the Outlook

object model. It is available as part of a binary array of bytes in the

PR_ATTACH_DATA_BIN (property tag 0x37010102) property, but you have to use a

lower level API to get at that data and then translate it from a binary blob

into ANSI or Unicode text.

The easiest way to do what you want is to use the SaveAsFile method of the

Attachment object to save the attachment to the file system and then use

your favorite file handling methods to load the file contents as a text

stream and search in that.

Assuming the item with the attachment is open the first part of the macro

would be something like this:

Dim objItem As Object

Dim attach As Outlook.Attachment

Set objItem = Application.ActiveInspector.CurrentItem

Set attach = objItem.Attachments.Item(1) 'assuming only 1 attachment

attach.SaveAsFile "c:\foobar.txt"

If the attachment is actually text and not an image or something else that

will save it to the indicated path as "foobar.txt", which then can be opened

and read as a file and text stream.

"MM" <MM> wrote in message

news:E537774C-D3A1-4ABC-8649-5FD84F3C4137@microsoft.com...
> I would like to be able to search email attachments for a given text
> string.
> Is this possilbe or would it require a macro? If a macro is required, does
> anyone have any idea where to start with this as I'm a bit stuck on how to
> acheive this.
> Regards,

> Martin
 
S

Sue Mosher [MVP]

You might want to upgrade to Outlook 2007, which can search across the

contents of attachments.

Sue Mosher

"MM" <MM> wrote in message

news:E537774C-D3A1-4ABC-8649-5FD84F3C4137@microsoft.com...
> >I would like to be able to search email attachments for a given text
> >string.
> > Is this possilbe or would it require a macro? If a macro is required,
> > does
> > anyone have any idea where to start with this as I'm a bit stuck on how
> > to
> > acheive this.
> > Regards,
>

>> Martin

>
 
Status
Not open for further replies.
Top