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
 
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
 
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
A Search folder and move the email Outlook VBA and Custom Forms 0
farrissf Outlook 2016 Optimizing Email Searches in Outlook 2016: Seeking Insights on Quick Search vs Advanced Search Features Using Outlook 0
E Outlook 365 Save Selected Email Message as .msg File - oMail.Delete not working when SEARCH Outlook VBA and Custom Forms 0
B Search and Find Email by Folder Name Outlook VBA and Custom Forms 2
J How do you disable address search box when typing @ in body of email? Using Outlook 0
D Create advanced search (email) via VBA with LONG QUERY (>1024 char) Outlook VBA and Custom Forms 2
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
M Search message, then (1) Jump to folder & (2) Select message that you searched for Outlook VBA and Custom Forms 2
G Search Folders and Jump to Folder Outlook VBA and Custom Forms 2
A 'search people' now asks me to 'press enter' Using Outlook 8
A Relocate Search Bar in Outlook Using Outlook 2
C Advanced search terms for "Outlook Data File" Using Outlook 1
T How to find or display the sub-folder name for an Archive Search Using Outlook 10
P Search folder: all emails sent to or from a domain Using Outlook 1
T Outlook365 search item listed as "potential matches" can't be opened Using Outlook 0
Victor_50 Outlook 2019 Jump to folder from search folder Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro GoTo user defined search folder Outlook VBA and Custom Forms 6
J Outlook search bar in Office 2021 Professional Using Outlook 1
T Outlook 365 Search Box reverting to old location Using Outlook 2
P Outlook 2013 search no longer works Using Outlook 2
C How to search for items in Outbox with multiple accounts? Using Outlook 20
J search doesn't find anything Using Outlook 1
kkqq1122 How would I add Search for attachment name Outlook VBA and Custom Forms 3
A Any way to force sort by/group by on search results with VBA? Outlook VBA and Custom Forms 1
C Search not accurate, but not indexing Using Outlook 9
H Outlook 2019 intermittent search results Using Outlook 0
D Advanced e-Mail search on from/to contact group only searches for first 20 contacts in group Using Outlook 0
mll persistently customise columns in outlook advanced search Using Outlook 3
S vba outlook search string with special characters Outlook VBA and Custom Forms 1
S VBA search string with special characters Outlook VBA and Custom Forms 1
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

Similar threads

Back
Top