[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to create VB Program that automatically forwards Outlook email

Posted on 2004-10-21
4
Medium Priority
?
255 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:ChWCIT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
jimbobmcgee earned 2000 total points
ID: 12369527
The following should be placed in a module in your Outlook macros:

    Sub StripAndForward(thisMail As Outlook.MailItem)
   
        Const strAddress    As String = "somebody@somewhere.com"
                                                '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.

HTH

J.
0
 

Author Comment

by:ChWCIT
ID: 12369739
jimbobmcgee,
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 .
0
 

Author Comment

by:ChWCIT
ID: 12369859
Nver mind jimbobmcgee, it is working now.  i had to change

Const blnAutoSend   As Boolean = False  'SEND FORWARD AUTOMATICALLY

to

Const blnAutoSend   As Boolean = True  'SEND FORWARD AUTOMATICALLY

Thanks for the help.
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12370874
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!!

J.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question