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.
Similar threads
Thread starter Title Forum Replies Date
H Search Email Header for Content Type Outlook VBA and Custom Forms 1
T How can you include Junk Email in Search Results like you can include Deleted Items? Using Outlook 3
A Outlook 2019 having issues with 'people search' and not making suggestions in email To: etc Using Outlook 12
W Create Search Folder excluding Specific Email Addresses Using Outlook 5
M possible to search Outlook for multiple email addresses at once? Using Outlook 1
M email search not working Using Outlook 1
skyfox VBA to search email subject field for a certain string Outlook VBA and Custom Forms 3
I Locating an email after search - Field Chooser Using Outlook 2
Les Email address search Using Outlook 1
J Search shows an email is in my Inbox but I can't see it there. Using Outlook 0
S O2010: Search for email using folderpath Using Outlook 2
O Inbox Search Results won't update when deleting or moving an email Using Outlook 12
I Search email with information in detailed headers Using Outlook 3
P Posts in Folder No Longer Group by Conversation Column After Search Using Outlook 0
O Advanced search - can I use booleans Using Outlook 3
Y Filter unread emails in a search folder vba help Outlook VBA and Custom Forms 0
M Reverting The Outlook Search Box Location (or other undesired additions) Using Outlook 1
M Something went wrong and your search couldn't be completed Using Outlook 1
M Disable Contact Card Results when using "Search People" in Outlook Ribbon Using Outlook 7
J outlook 2007 doesn't let me choose which .pst to search Using Outlook 2
P outlook 2008 search box criteria couldn't be saved Using Outlook 2
C Outlook with Office365 - search across account, by date rate, in multiple folders - how? Using Outlook 2
D Custom Search Folders not refreshing/updating automatically Using Outlook 0
L New Location for the Search Bar Using Outlook 6
J Outlook 2016 After a search in all mailboxes, where is each message that was found? Using Outlook 6
King Mustard Sort search groups by amount of items? Using Outlook 1
V Outlook 2016 will not move emails in search results Using Outlook 4
T Search for incoming e-mails for a specified time range Using Outlook 1
S outlook 2007 calendar search Using Outlook 6
M Outlook macro to automate search and forward process Outlook VBA and Custom Forms 6
J Message search and edit, another way? Outlook VBA and Custom Forms 4
S Create A Search Folder That Looks For Message Class? Outlook VBA and Custom Forms 0
R Outlook for Mac - Advanced Search and Tracking Sent Emails Using Outlook 0
R Search/Jump to a folder by typing its name Outlook VBA and Custom Forms 1
M Sent mail not showing in Sent Items folder; but they can be found with Search Using Outlook 3
W Search Incomplete Outlook 2016 Using Outlook 5
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 4
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 0
A Using or not using apostrophes in search terms has this changed? Using Outlook 0
R outlook address book search broken Using Outlook 2
K Outlook.com is not showing, or finding via search, all my Contacts (People) Using Outlook 0
R What's supposed to appear when just clicking into the search field? Using Outlook 7
A Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3
B Instant search with special characters Using Outlook 1
A Search folder refresh Outlook VBA and Custom Forms 3
B Advanced Search in MS Outlook by VBA and SQL Outlook VBA and Custom Forms 2
F Search folder for tasks in all task folders Using Outlook 1
W Outlook 2016 search problem persists after applying all known solutions Using Outlook 12
B Looking to filter (or just find/search) for only messages that the sender has sent more than 1 messa Using Outlook 2
B Search: Cannot find which Folder Contains a Message Using Outlook 3

Similar threads

Top