MoveTo

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.
 
K

Ken Slovak - [MVP - Outlook]

Does that user actually have CDO installed? Any other errors preceding that
one? Is that user using Outlook 2000 in Internet only mode?
 
L

Leon Mayne [MVP]

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.
 
K

Ken Slovak - [MVP - Outlook]

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.
 
V

vb_prog

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?
 
K

Ken Slovak - [MVP - Outlook]

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.
 
V

VB_Prog

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?
 
K

Ken Slovak - [MVP - Outlook]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top