VBA script does not work

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
 

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