A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook not always executes an script from a rule



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old September 1st 06, 05:59 PM posted to microsoft.public.outlook.program_vba
Carlos
external usenet poster
 
Posts: 24
Default Outlook not always executes an script from a rule

Hello all,

I have the following code, that is used in a rule when a message arrives.
The rule should take a message with "newticket" on the subject and move it to
helpdesk_unprocessed folder and run the script.

The problem is that it runs sometimes and sometimes not. When it does not
run, if I open the Visual Basic Editor and delete objItem As MailItem from
the beggining, leaving the parethensis (), i can run the macro and always it
works.

I'm really confused, any help? thanks very much,
Carlos

Sub executeMacro(objItem As MailItem)
Dim outApp As New Outlook.Application
Dim nsp As Outlook.NameSpace
Dim mpf As Outlook.MAPIFolder
Dim mpfSubFolder As Outlook.MAPIFolder
Dim flds As Outlook.Folders
Dim msg As Object
Dim msgSubject As String
Dim summary As String
Dim description As String
Dim processed_folder As Outlook.MAPIFolder

Set nsp = outApp.GetNamespace("MAPI")
Set mpf = nsp.GetDefaultFolder(olFolderInbox)
Set flds = mpf.Folders
Set mpfSubFolder = flds.GetFirst
Set processed_folder = flds("Helpdesk_Processed")
Do While Not mpfSubFolder Is Nothing
If mpfSubFolder.Name = "Helpdesk_Unprocessed" Then

For Each msg In mpfSubFolder.Items
If InStr(1, msg.Subject, "newticket") 0 Then

MsgBox ("hola")

msg.Move processed_folder

End If
Next
End If
Set mpfSubFolder = flds.GetNext

Loop
End Sub




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rule 'run a script' not running my script [email protected] Outlook and VBA 3 May 30th 06 01:09 PM
"Run a script" rule triggers but script does not execute Trey Shaffer Outlook and VBA 7 April 8th 06 12:34 AM
Problem running a VBA script from an Outlook rule Olivier Langlois Outlook and VBA 5 March 16th 06 10:03 PM
Problem running a VBA script from an Outlook rule Olivier Langlois Add-ins for Outlook 5 March 16th 06 10:03 PM
Script in Rule clarkel Outlook and VBA 2 February 2nd 06 09:20 PM


All times are GMT +1. The time now is 08:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.