Need help with Outlook rule option "run a script"


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
 
Ad

Advertisements

S

Sue Mosher [MVP-Outlook]

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
 
X

XxLicherxX

Hi Sue,

Thanks for the response. Where do I write this procedure?

Thanks
 
S

Sue Mosher [MVP-Outlook]

In the Outlook VBA environment, either in the built-in ThisOutlookSession module or any regular module you want to add to the VBA project.
 
X

XxLicherxX

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
 
S

Sue Mosher [MVP-Outlook]

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
 
Ad

Advertisements

Joined
Jun 26, 2016
Messages
2
Reaction score
0
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top