Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using VBS to forward an email

Posted on 2004-04-13
7
Medium Priority
?
934 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 375 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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

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

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
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…
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…

609 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