MoveTo

  • Thread starter Thread starter VB_Prog
  • Start date Start date
V

VB_Prog

I'm trying to make a sub that moves mail from one folder to another that the
user selects. A simplified version of this is here:

Sub moveMessages()
Dim objNS As NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objMessage As Object
Dim objCDO As MAPI.Session
Dim oOL As Outlook.Application
Dim strFldId As String
Dim strFldStoreId As String
Dim strMsgId As String
Dim strMsgStoreId As String
Dim entryIDs() As String
Dim selCount As Integer
Dim x As Integer

Set oOL = CreateObject("Outlook.Application")
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
Set objCDO = CreateObject("MAPI.Session")
objCDO.Logon "", "", False, False
strFldId = objFolder.EntryID
strFldStoreId = objFolder.StoreID
Set objFolder = objNS.GetFolderFromID(strFldId, strFldStoreId)
If TypeName(objFolder) <> "Nothing" Then
selCount = oOL.ActiveExplorer.Selection.Count
ReDim entryIDs(selCount)
For x = 1 To selCount
' Build an array of the entryIDs
strMsgId = oOL.ActiveExplorer.Selection.Item(x).EntryID
strMsgStoreId = oOL.ActiveExplorer.Selection.Item(x).Parent.StoreID
entryIDs(x) = strMsgId
Next

For x = 1 To UBound(entryIDs)
' Move messages
Set objMessage = objCDO.GetMessage(entryIDs(x), strMsgStoreId)
objMessage.MoveTo strFldId, strFldStoreId
Next
End If
End Sub

However, someone using Outlook 2000 is getting the error:
[Collaboration Data Objects - [MAPI_E_INVALID_ENTRYID(80040107)]]
on the "objMessage.MoveTo" line.
Does anyone know why? It woks fine both in my copy of Outlook 2003 and a
test copy of Outlook 2000 I have.
 
Does that user actually have CDO installed? Any other errors preceding that
one? Is that user using Outlook 2000 in Internet only mode?
 
Ken said:
Does that user actually have CDO installed? Any other errors
preceding that one? Is that user using Outlook 2000 in Internet only
mode?

They have CDO installed and referenced. No other errors, and they're using
POP only.
 
POP only doesn't say which mode they are using. Check in Help, About
Microsoft Outlook to see that. If it's Internet only mode then maybe
something in that mode, which has a crippled MAPI and therefore CDO might be
the problem. If they are in that mode they can switch to corporate/workgroup
mode and see if that makes any difference. Another thing to check is the
build of Outlook. It might be something restricted in one and not the other.
 
Ken said:
POP only doesn't say which mode they are using. Check in Help, About
Microsoft Outlook to see that. If it's Internet only mode then maybe
something in that mode, which has a crippled MAPI and therefore CDO
might be the problem. If they are in that mode they can switch to
corporate/workgroup mode and see if that makes any difference.
Another thing to check is the build of Outlook. It might be something
restricted in one and not the other.

Sorry, don't know what happened to my last post!
They returned and said they actually are in internet only mode. Is there any
way of fixing the crippled MAPI for internet only mode?
 
Only by changing modes to corporate/workgroup mode. I don't *know* that's
the problem, that's only a guess. But it's easy enough to change modes and
then back again. For how to do that and what changes will be seen in how
Outlook operates see http://www.slipstick.com/outlook/choosingmode.htm

In many of my addins I just test for Internet only mode and say I don't
support it if it's there.
 
Ken said:
Only by changing modes to corporate/workgroup mode.

OK, they tried changing to corporate mode and still having the same problem.
Can you think of anything else that might be wrong?
 
Not offhand. It may be time to visit that computer and run in debug mode and
step the code to see what's wrong and where the initial error occurs.
 
Back
Top