View Single Post
 
Old 12-06-2005, 02:10 PM
GivenRandy GivenRandy is offline
Novice
 
Join Date: Dec 2005
Posts: 1
GivenRandy
Default Can't Move the Items

I have some inherited code that works under my login, but not under others. Which doesn't seem to make sense because we can open the PST under the other logins, it's just that the code gives an error "Can't move the items" when it tries to move in the function below. Any ideas? [Hmm, keeps losing the indentation/spaces in the copy-paste]

--------------------------------------
Public Function CopyMailFromReferenceToTarget(ByVal uniqueMailId As String, Optional ByVal blnCopyToInbox As Boolean = False) As Boolean Implements IMailAdapter.CopyMailFromReferenceToTarget

Dim copyFolder As Outlook.MAPIFolder
Dim itemToBeAdded As Object
Dim itemCopy As Object
Dim itemParent As Outlook.MAPIFolder

Try
CopyMailFromReferenceToTarget = True

If _mailApp Is Nothing Then
Throw New ApplicationException("Object not initialized. Initialize the object first.")
End If

If _referenceMailDatabase Is Nothing Then
Throw New ApplicationException("Reference Pst file not set. Set it first.")
End If

'Get the mail to be added from reference personal folder
itemToBeAdded = GetItem(uniqueMailId, _referenceMailDatabase.StoreID)

'Make the copy of the mail
itemCopy = itemToBeAdded.Copy()

'Get the folder where to copy
itemParent = itemToBeAdded.Parent

If _targetMailDatabase Is Nothing Then
Throw New ApplicationException("Target Pst file not set. Set it first.")
End If

If blnCopyToInbox Then
copyFolder = GetFolder("\\Personal Folders\Inbox", _targetMailDatabase)
Else
copyFolder = GetFolder(itemParent.FolderPath, _targetMailDatabase)
End If

'Copy the mail to the desired mail datababase
itemCopy.Move(copyFolder)

Catch ex As Exception
NotifyUser(ex.Message, MessageBoxIcon.Error)
CopyMailFromReferenceToTarget = False

Finally
FreeComObject(itemCopy)
FreeComObject(itemToBeAdded)
FreeComObject(copyFolder)
FreeComObject(itemParent)
End Try

End Function
--------------------------------------
Reply With Quote