![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]() 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: 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Does the Shell method work in VB Script? | Culverin | Outlook and VBA | 4 | October 29th 11 06:58 AM |
VBA script does not work | Aaron | Outlook and VBA | 0 | February 9th 09 04:31 PM |
Outlk 2k3 Script: Saving Excel File programticaly from OUTLOOK SCRIPT | news.microsoft.com | Outlook and VBA | 3 | November 22nd 06 03:33 PM |
Does the Shell method work in VB Script? | Culverin | Outlook - Using Forms | 0 | August 25th 06 02:22 PM |
Outlook form with VB script wont work | Hellstern | Outlook - Using Forms | 1 | March 31st 06 02:21 PM |