[RESOLVED] Cannot move emails
Hi guys!!!
:wave: :wave: :wave:
Need help. Cannot move e-mail to folder. Don't know why.
VB Code:
Dim OrganizerApplication As New Outlook.Application
Dim OrganizerNS As Outlook.NameSpace
Dim OrganizerFolder As Outlook.Folders
Dim DestFolder As MAPIFolder
Dim InboxItem As Outlook.MailItem
Dim InboxCount As Integer
Dim DestFolderCount As Integer
Dim Sender As String
Dim CompareFolder As String
Set OrganizerNS = OrganizerApplication.GetNamespace("MAPI")
Set OrganizerFolder = OrganizerNS.Folders.Item("Mailbox - Ian Eco (DHL PH)").Folders
Set DestFolder = OrganizerNS.Folders.Item("IAN Personal")
InboxCount = 1
Do While Not InboxCount = OrganizerFolder.Item(2).Items.Count
On Error Resume Next
Set InboxItem = OrganizerFolder.Item(2).Items.Item(InboxCount)
If Err = 13 Then
Else
Sender = InboxItem.SenderEmailAddress
DestFolderCount = 1
Do While Not DestFolderCount = DestFolder.Folders.Count + 1
CompareFolder = Replace(DestFolder.Folders.Item(DestFolderCount), " ", ".")
If InStr(1, Sender, UCase(CompareFolder)) > 0 Then
InboxItem.Move (DestFolder)
End If
DestFolderCount = DestFolderCount + 1
Loop
End If
Err = 0
InboxCount = InboxCount + 1
Loop
Re: [RESOLVED] Cannot move emails
Are these all top level pst files or folders or ? Can you draw teh folder structure or attact a small screen shot?
Re: [RESOLVED] Cannot move emails
Quote:
Originally Posted by RobDog888
Are these all top level pst files or folders or ? Can you draw teh folder structure or attact a small screen shot?
Oh, thanks for your reply.
I'm sorry if I did not told you that I found the error.
I have forgotten that when you use the parenthesis in an expression it will definitely read as a function and not a sub procedure.
VB Code:
InboxItem.Move(Something)
Will not work. It should be these: