Highlight keyword in mail body

  • Thread starter Thread starter wisemax
  • Start date Start date
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
 
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
 
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
 
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
 
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).
 
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
 
Back
Top