VBA script does not work

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

I am trying to write my first Outlook VBA code (I have written VBA in Excel
and Access so far) that triggers on a certain rule. In order to check to see
if the code is even firing, I have tried to create a simple message box that
shows the Sender string from a MailItem. However, know that the rule should
trigger, I still don't see any message box. I have check my security
settings, and they are set to allow all macro codes with a warning. Thank
you for any advice/help!

The rule and code are as follows:
Rule:
Apply this rule after the message arrives through xxx account run
Scripts.Test2

Code:
Option Explicit

Public Sub Test2(myMailItem As Outlook.MailItem)

Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.Folder
Dim arrFolders() As String

Dim Sender As String
Dim Response As String

Set objApp = Application
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.item("ITCS (POP)\Inbox")

Sender = myMailItem.To
Response = MsgBox(Sender, vbYesNo, "Sender")

End Sub
 
You can set a brealpoint (f9) on the Public Sub line. If the script is being
called, the code execution will stop there. Then you can walk trough it step
by step (f8) and see what's going on.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>



Am Mon, 9 Feb 2009 08:31:01 -0800 schrieb Aaron:
 
Back
Top