Solved

Using VBS to forward an email

Posted on 2004-04-13
7
864 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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
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: …

914 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

19 Experts available now in Live!

Get 1:1 Help Now