How to create VB Program that automatically forwards Outlook email

Does anyone have a Visual Basic script that will automatically check all new Outlook email for a certain keywords (ie. "you", or "help"), remove any attachments from the email, and forward just the body of the email to another email address?  Thanks in advance.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The following should be placed in a module in your Outlook macros:

    Sub StripAndForward(thisMail As Outlook.MailItem)
        Const strAddress    As String = ""
                                                'FORWARDING ADDRESS
        Const blnAutoSend   As Boolean = False  'SEND FORWARD AUTOMATICALLY
        Dim objFwd As Outlook.MailItem
        Dim objAtt As Outlook.Attachment
        For Each objAtt In thisMail.Attachments
            objAtt.Delete                       'DELETE EACH ATTACHMENT
        Next objAtt
        Set objFwd = thisMail.Forward           'CREATE FORWARD MAIL
        objFwd.Recipients.Add strAddress        'ADD RECIPIENT
        If blnAutoSend = True Then objFwd.Send Else objFwd.Display
                                                'AUTOSEND OR DISPLAY
        Set objFwd = Nothing
        Set objAtt = Nothing
        Set thisMail = Nothing                  'CLEANUP
    End Sub

You can now set a message rule to search for the words you want to filter from the subject or body, telling the rule to run a custom script if those words are found.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChWCITAuthor Commented:
I set up the module and created a rule to run that script when the keywords are found.  It seems to be running the script, however the emails are never received at the new address.  I have tried to with several addresses .
ChWCITAuthor Commented:
Nver mind jimbobmcgee, it is working now.  i had to change

Const blnAutoSend   As Boolean = False  'SEND FORWARD AUTOMATICALLY


Const blnAutoSend   As Boolean = True  'SEND FORWARD AUTOMATICALLY

Thanks for the help.
No problem, ChWCIT

I put that blnAutoSend line in so you can check the mail looks correct befrore you send it.  Its a debug thing...

Thanks for the points; glad to help!!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.