Can't move items

  • Thread starter Thread starter Kiran
  • Start date Start date
K

Kiran

I ma writing Outlook COM Addin in VB6. The Addin checks if an item is added
or moved to/from a predefined folder (X) from/to any other folder. It
movement happens, it prompts to enter a password. If the password is invalid,
the item is restored to original folder.
-If mail Added to folder 'X' from folder 'A'
-Prompt for password in ItemAdd of 'X'.
-If password is invalid, move it back to 'A'
Similarly for ItemRemove.
As moved Item is not available in ItemRemove, I monitor all the other
folders for ItemAdd and store the moved item and use it in ItemRemove.
Now, If an item is moved to 'X' and invalid passowrd, it is moved back to
say 'A'. And if the same mail is moved again to 'X', and invalid password,
then I get an error 'Can't move items.' If some other item is moved, then it
works fine.
I even tried in C++ COM. I am getting the same error over there. Any help
would be highly appreciated.

Regards,
Kiran
 
It works fine when? Does it work if you try to move it again if you detect
that error? Is that in the same procedure? Does it work if you step your
code in the debugger?
 
Do not store items, store the entry ids and reopen the items as needed using
Namespace.GetItemFromID

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
Consider the following scenario:
Folder 'X' is protected.
1. If mail1 is moved to folder 'X' from folder 'A' and password is invalid,
then the mail1 is restored back to folder 'A'.
2. If mail1 is again moved to folder 'X' from folder 'A' and again password
is invalid, then I get error 'Can't move items'. During Debug and otherwise
also.
If mail2 is moved in step 2, instead of mail1, and password is invalid, then
also the mail2 is restored.
The problem occurs if the same mail is moved in succession.

I am actually moving the parameter item in ItemAdd event handler of folder
'X'.

I also monitor all the folders' Items otherthan 'X' for ItemAdd event to
identify which item was removed from folder 'X'. If I donot monitor those
Items, this error does not occur. In that case I can not identify which item
was removed from folder 'X'.

Please let me know if you need more information.

Regards,
Kiran
 
Show your ItemAdd code, let's see if something jumps out as a problem.
 
Hello Ken,

I checked the properties of the mail in 2 instances. The Parent is set to moved folder 'X' in first move. During second move, the parent is set to source folder 'A'. If I do not monitor Items of folder 'A', then there is no issue. But I need to monitor folder 'A' also.

Here is my ItemAdd handler.
Private Sub mEncryptedItems_ItemAdd(ByVal Item As Object)
'Check password
'If pass word is invalid
Dim mail As MailItem
Set mail = Item
Set tempMail = mail.Move(mSpCurrentFolder)
Set tempMail = Nothing

End Sub

I even tried dereferencing the mail by setting it to Nothing and then use GetItemFromID(entryID, storeID). But no use.

Thanks & Regards,
Kiran
 
The code looks OK. I'm wondering if a delay would make any difference, i.e:

Dim mail As MailItem

DoEvents

Set mail = Item

DoEvents

Set tempMail = mail.Move(mSpCurrentFolder)

Other than that I'm out of ideas.
 
Back
Top