C
crazyv
Hello all,
I have below code in a single Outlook Module. It runs as expected, but only
when i include a line - which does not have any use for within the code!
Which is calling a MsgBox function.
This is probably a very simple explanation which I am not finding for this.
Here is the code:
Sub createMove()
Dim myOlApp As New Application
Dim namespace As namespace
Dim inbFolder As MAPIFolder
Dim myFolder As MAPIFolder
Dim resFolder As MAPIFolder
Dim aa, abc As String
Dim objResult As Results
Dim objSch As Search
Dim item As MailItem
Set namespace = myOlApp.GetNamespace("MAPI")
Set inbFolder = namespace.GetDefaultFolder(olFolderInbox)
Set resFolder = inbFolder.Folders("res")
aa = "urn:schemas:mailheader:subject = 'test'" '& abc
Const strS As String = "'Inbox\test'"
Const strTag As String = "SubjectSearch"
Set objSch = AdvancedSearch(Scope:=strS, Filter:=aa,
SearchSubFolders:=True, Tag:=strTag)
Set objResult = objSch.Results
MsgBox "?" '' IF I DONT HAVE THIS IT WONT GET PAST THIS LINE!
For Each item In objResult
MsgBox "item: " & item.Subject
item.Move resFolder
Next
End Sub
I have below code in a single Outlook Module. It runs as expected, but only
when i include a line - which does not have any use for within the code!
Which is calling a MsgBox function.
This is probably a very simple explanation which I am not finding for this.
Here is the code:
Sub createMove()
Dim myOlApp As New Application
Dim namespace As namespace
Dim inbFolder As MAPIFolder
Dim myFolder As MAPIFolder
Dim resFolder As MAPIFolder
Dim aa, abc As String
Dim objResult As Results
Dim objSch As Search
Dim item As MailItem
Set namespace = myOlApp.GetNamespace("MAPI")
Set inbFolder = namespace.GetDefaultFolder(olFolderInbox)
Set resFolder = inbFolder.Folders("res")
aa = "urn:schemas:mailheader:subject = 'test'" '& abc
Const strS As String = "'Inbox\test'"
Const strTag As String = "SubjectSearch"
Set objSch = AdvancedSearch(Scope:=strS, Filter:=aa,
SearchSubFolders:=True, Tag:=strTag)
Set objResult = objSch.Results
MsgBox "?" '' IF I DONT HAVE THIS IT WONT GET PAST THIS LINE!
For Each item In objResult
MsgBox "item: " & item.Subject
item.Move resFolder
Next
End Sub