Using a script for email alerts

R

Roy N

I would like to create a rule for Outlook 2003 which will send an email if
certain conditions within the rule are met. The destination address will be
static, as will everything in the email.

I basically want to create an Outlook rule that says "If email from xxx is
received run script" And I want the script to send an email that says "You
received an important email." This same message is always sent to the same
email address.

Seems to me that this would be a very basic script. But I have no idea if
such a script is programmatically possible for Outlook. I have experience
with VB Script (as well as C++ and lots of other programming) but I don't
know the first thing about writing scripts for Outlook.

If what I want to do is possible, let me know and I'll start researching. If
what I want to do is possible and you want to be extra helpful, let me know
and give me some pointers to get me started :)
 
S

Sue Mosher [MVP-Outlook]

A "run a script" rule action actually uses not an external script but a VBA procedure with a MailItem or MeetingItem as its parameter. That item is processed by the code:


Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
' do stuff with msg, e.g.
MsgBox msg.SUbject

Set msg = Nothing
Set olNS = Nothing
End Sub

Of course, in your scenario, you don't seem to care about the item, so all you need to do is create a message and send it:

Set mail = Application.CreateItem(olMail)
With mail
.To = "(e-mail address removed)"
.Subject = "whatever"
.Body = "some stuff"
.Send
End With

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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