Thread: [Solved] Microsoft Outlook Movemail
View Single Post
 
Old 11-21-2005, 07:13 PM
Matrix's Avatar
Matrix Matrix is offline Windows 10 Office 2010
Admin
 
Join Date: Jan 2005
Posts: 448
Matrix is on a distinguished road
Default

Sorry that I didn't make it clear. The reason for the error is explained in my previous post, here is the code changes (Tested on my Outlook 2003):

1. Add the function from http://www.outlookcode.com/d/code/getfolder.htm
Quote:
Public Function GetFolder(strFolderPath As String)As MAPIFolder
' folder path needs to be something like
' "Public Folders\All Public Folders\Company\Sales"
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim I As Long
On Error Resume Next

strFolderPath = Replace(strFolderPath, "/", "\")
arrFolders() = Split(strFolderPath, "\")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For I = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I))
If objFolder Is Nothing Then
Exit For
End If
Next
End If

Set GetFolder = objFolder
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Function
2. Change
Quote:
DestFldr:=CurrentNameSpace.GetFolderFromID(strTarg FldrID)
to
Quote:
DestFldr:=GetFolder(strTargFldrID)
3. Change
Quote:
If MoveMail(Item, Inbox.Folders.Item("Processed").EntryID) Then
to
Quote:
If MoveMail(Item, "Personal Folders\outside") Then
Personal Folders\outside is the complete path of my test folder.

Please note that the changed code only deals with the folders outside of "Inbox".
Reply With Quote