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