Solved

Using VBS to forward an email

Posted on 2004-04-13
7
880 Views
Last Modified: 2007-12-19
Hello everyone!

I'm trying to do something here and I'm not a VBS expert.  Hope someone can lead me in the right direction.

I need a VBS or some sort of macro for Outlook 2002/Exchange 2k that will forward an email to a specified address and put a one word command in the body of the message.  

We have a mailbox that our users forward spam to and then we forward it to our spam filter.  Great spam filter huh?

Thanks in advance for everyone's help.

0
Comment
Question by:rchandler6473
[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
  • 3
  • 3
7 Comments
 
LVL 7

Expert Comment

by:rosesolutions1
ID: 10818596
Lots of ways - before we all give you options, can you answer these 2 questions?

How do you want to trigger this code?
(a) Automatically, say using Outlook rules
(b) Manually, via a button on the toolbar

Do you need to deploy it to lots of workstations (ie. need it to be installable), or only a few (ie. could do it manually on each one)?
0
 

Author Comment

by:rchandler6473
ID: 10818672
I think I want to do it automatically using the rules.  This will only be run on two workstations and if necessary can be run manually.  Right now I have one of my technicians forwarding them manually and it takes quite a long time to forward 900+ messages a day.  Rules won't quite cut it by themselves due to it not being able to put something in the body of the message.

Hope this is what your asking.

Thanks!
0
 
LVL 7

Accepted Solution

by:
rosesolutions1 earned 125 total points
ID: 10818785
OK
Step 1: Create the Code
Open the VBA editor for Outlook (Alt-F11). By default, Project1 will be selected and there will be a big blank window ready for code. Paste the following into it:

Sub FwdToMe(Item As Outlook.MailItem)
    Set myitem = Item.Forward
    myitem.Recipients.Add "PUT YOUR EMAIL ADDRESS HERE"
    myitem.Body = "WHATEVER TEXT YOU WANT TO INSERT" & vbCrLf & vbCrLf & myitem.Body
    myitem.Send
End Sub

(the vbCrLfs are carriage returns - put more or less as suites you.)

Click File/Save

Step 2: Connect to a rule
Create an Outlook rule, with the action as "Run a script" - select the only one you have (which will say something Project1.ThisOutlookSession.FwdToMe).

Done.
0
SuperAntiSpyware Licenses Discounted by 25% !

Exclusive offer to Experts Exchange Members!
Buy SuperAntiSpyware License(s) from us and save 25% on the regular purchase price.
- Includes Full SuperAntiSpyware Vendor Support Entitlements
- Your Subscription does not begin until you activate your license
- Buy for your friends

 

Author Comment

by:rchandler6473
ID: 10821828
I got it to work once, but after that it no longer works and I get a error saying the operation failed almost immediately.  Also, when the VBA editor comes up it doesn't have a window to post code into.  I have to tell it to insert something so I chose a module.

Gettting close though.
0
 
LVL 7

Expert Comment

by:rosesolutions1
ID: 10822935
Thats odd. Put the code in the module then - it will still work.
0
 

Author Comment

by:rchandler6473
ID: 10823036
With a slight modification of the code I got it to work.

Sub FwdToMe(Item As Outlook.MailItem)
    Dim myitem As Outlook.MailItem
    Dim address As String
    Set myitem = Item.Forward
    address = "email address"
    myitem.Recipients.Add address
    myitem.Body = "WHATEVER TEXT YOU WANT TO INSERT" & vbCrLf & vbCrLf & myitem.Body
    myitem.Send
End Sub

Only other problem that I'm having is the Outlook security feature.  It pops up every message and asks if it can have access to it.  I read something on the board about a program called redemption that can bypass the security.  I'll take a look at that.
Any suggestions to fix that little security problem?
0
 
LVL 13

Expert Comment

by:stefri
ID: 10850824
Even if the question is PAQ, a little follow up:
Download redemption from:
Dowload an install Redemption http://www.dimastr.com/redemption/download.htm 
Read the docs: http://www.dimastr.com/redemption/objects.htm then

Sub FwdToMe(Item As Outlook.MailItem)
    Dim myitem As Outlook.MailItem, SafeItem as Object
    Dim address As String
    set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of Redemption.SafeMailItem
    Set myitem = Item.Forward
    SafeItem = myItem
    address = "email address"
    SafeItem.Recipients.Add address
    SafeItem.Body = "WHATEVER TEXT YOU WANT TO INSERT" & vbCrLf & vbCrLf & myitem.Body
    SafeItem.Send
    set SafeItem = nothing
End Sub

would solve the security problem
Stefri
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Read this checklist to learn more about the 15 things you should never include in an email signature.
Changing a few Outlook Options can help keep you organized!
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

737 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