multiple macro/script in 1 outlook

A

ah

Can I have more than 1 script running in 1 outlook mailbox?

I've created a script as follows previously:

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

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
' do stuff with msg, e.g.
Set rpl = msg.Reply
rpl.Body = "testing" & vbCrLf & rpl.Body
rpl.Subject = "Authorization fail"
rpl.Send


Set msg = Nothing
Set olNS = Nothing
End Sub

Sub test()

End Sub

The above script should be run when the e-mail was sent by those
unauthorized personnel.

Now, I wish to run another script to generate an auto reply e-mail to the
authorized personnel with another message, for example: Thanks for your
e-mail etc. But, I found that I can only put in 1 script in the macro. Kindly
advice me on how to resolve this issue.

Thanks in advance
 
S

Sue Mosher [MVP-Outlook]

Create a second macro or, better yet, consolidate your code into a single procedure.

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

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

ah

And I think I've left out something in my previous message

In fact, I wish to get the following result:

1. Run rules when I receive mail
2. Send an auto reject mail and move the message to a "reject" folder when I
receive the mail from those sender's address that contain "abc".
3. Send an auto reply mail when I receive mail from someone in my address book

Thanks.
 
M

Michael Bauer

Am Tue, 20 Jun 2006 19:43:01 -0700 schrieb ah:

You can e.g. add that into the existing macro. Check the sender address and
use an If ... Then ... Else
 
A

ah

Hi;

Can you help me on this? I get errors when I add in the code myself. My
original script is as follows:

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

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
' do stuff with msg, e.g.
Set rpl = msg.Reply
rpl.Body = "testing" & vbCrLf & rpl.Body
rpl.Subject = "Authorization fail"
rpl.Send


Set msg = Nothing
Set olNS = Nothing
End Sub

Sub test()

End Sub

Can you guide me on how to add in those code?
 
M

Michael Bauer

Am Tue, 20 Jun 2006 22:52:01 -0700 schrieb ah:

Please show us what you have added.
 
A

ah

Yup, I manage to have 2 scripts , but I'm facing problem in setting the
rules. The rule that I've set is as follows:

1. Apply the rules when message arrives
2. run the auto notification script when sender is in specific address book

The above seems to work well, as it manages to send out an auto notification
e-mail to the sender if they are in my address book.

Can you please advice me how to set a rules to perform the following:
1. If the sender is not in my address book, run the 2nd script, i.e the auto
reject script

Thanks
 
S

Sue Mosher [MVP-Outlook]

Create a rule with no conditions, a "run a script" action, and an exception -- except if sender is in my address book.

--
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