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