Solved

Using VBS to forward an email

Posted on 2004-04-13
7
860 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
  • 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now