Need help with Outlook rule option "run a script"

  • Thread starter Thread starter XxLicherxX
  • Start date Start date
X

XxLicherxX

Hello everyone,


I wish to run a custom script as part of a certain Outlook (2003) rule.

The problem is whenever I run the "create new rule" wizard and select
"run a script" nothing is listed for scripts. I don't even have browse
button to go search for the script. The only thing that comes up is a
box that has a blank window (for the scripts) and then an "OK" button
and "Close" button.


How do I add scripts to this?


Thanks
 
You must create a VBA procedure (not, technically, a script) first, using this syntax:

Sub MyProcedure(myMailItem as Outlook.MailItem)
' your code to work with myMailItem goes here
' for example:
MsgBox myMailItem.Subject
End Sub
 
In the Outlook VBA environment, either in the built-in ThisOutlookSession module or any regular module you want to add to the VBA project.
 
Hi Sue,

I have written a simple script using Outlook's VBA editor. How do I get
this to show up in the "run a script" part of the "create a rule"
wizard?

Thanks
 
A VBA procedure for use with a "run a script" rule needs to be a Public Sub with a MailItem as an argument:

Public Sub MyMacro(msg as MailItem)
Dim strID as String
Dim olNS as Namespace
Dim olMail as MailItem

strID = msg.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(strID)
' do stuff with olMail

Set olMail = Nothing
Set olNS = Nothing
End Sub
 
Hello Sue,
Hope you doing good.!

I Wish to write a custom VBA Script .. Where I can pop-out in a new window for a specific emails that i receive...in a forward mode with Auto-filled details like To , from , bcc and cc .. so all I need to click send button after validating every thing.
Before forwarding I also need to change the subject and few line in body
Can you help with the which function should i use to change or remove the few text in body?

Please help.!

Thanks.!
Lucky
 
Back
Top