Highlight keyword in mail body

W

wisemax

I got many emails every day. Can I use VBA to search every mail in my
inbox, and highlight the keywords (I have a list of keywords)? Further,
if a keyword exit in a mail, flag the mail so I will be able to read
these mails first?

For this purpose, if you have other approaches, please advise.

Thanks in advance.

Hong
 
J

John Blessing

I got many emails every day. Can I use VBA to search every mail in my
inbox, and highlight the keywords (I have a list of keywords)? Further,
if a keyword exit in a mail, flag the mail so I will be able to read
these mails first?

For this purpose, if you have other approaches, please advise.

Thanks in advance.

Hong

Yes, if you are adept in VBA and are reading your emails as richtext or html
(or I guess you could highlight plain text with * characters)

Alternatively, use, Tools, Organize, using colors, Automatic formatting.
Wouldn't highlight key phrases within the body, but would be a lot simpler.

--
John Blessing

http://www.LbeHelpdesk.com - Help Desk software priced to suit all
businesses
http://www.room-booking-software.com - Schedule rooms & equipment bookings
for your meeting/class over the web.
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook, find/replace,
send newsletters
 
W

wisemax

It was quick!!!!! Thank you John.

I never write VBA code for Outlook, although I write a lot of codes for
Excel. Can you share some codes to get me started? I will modify them
myself.

Hong
 
W

wisemax

It was quick!!!!! Thank you John.

I never write VBA code for Outlook, although I write a lot of codes for
Excel. Can you share some codes to get me started? I will modify them
myself.

Hong
 
D

Diane Poremsky [MVP]

Visit outlookcode.com - while vba is vba, because outlook uses so many
different windows and doesn't have a macro recorder for you to learn from,
it's not as simple as writing vba for excel (or word).

--
Diane Poremsky [MVP - Outlook]
Author, Teach Yourself Outlook 2003 in 24 Hours
Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide)
Need Help with Common Tasks? http://www.outlook-tips.net/beginner/



Subscribe to Exchange Messaging Outlook newsletter:
(e-mail address removed)
 
J

John Blessing

It was quick!!!!! Thank you John.

I never write VBA code for Outlook, although I write a lot of codes for
Excel. Can you share some codes to get me started? I will modify them
myself.

Hong

Not tested but should give you the general idea:

Private Sub Application_NewMail()

Dim objOl As Outlook.Application
Dim objNameSpace As Outlook.NameSpace

Dim objMailitem As Outlook.MailItem
Dim objFolder As MAPIFolder
dim lPos as long

Dim lIndex As Long

Set objOl = New Outlook.Application
Set objNameSpace = objOl.GetNamespace("MAPI")
objNameSpace.Logon

Dim strOrderBody As String


On Error Resume Next
Set objFolder = objNameSpace.GetDefaultFolder(olFolderInbox)
lIndex = 1
Do While lIndex <= objFolder.Items.Count
Set objMailitem = objFolder.Items(lIndex)
If Err.Number = 0 Then
If objMailitem.UnRead Then
lpos = instr(1, objmailitem.body ,"yourphrase")
do while lpos <> 0 and lpos < len(objmailitem.body)
if lpos > 0 then
objmailitem.body = left (objmailitem.body
,lpos-1) & "****" & _
mid ( objmailitem.body , lpos )
end if
lpos = instr(lpos + len("yourphrase"), objmailitem.body
,"yourphrase")
loop
objmailitem.save
end if

end if
lIndex = lIndex +1
loop

end sub

--
John Blessing

http://www.LbeHelpdesk.com - Help Desk software priced to suit all
businesses
http://www.room-booking-software.com - Schedule rooms & equipment bookings
for your meeting/class over the web.
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook, find/replace,
send newsletters
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top