![]() |
Cannot Create Folder -- VB.NET
Last chance for VB.NET on this one. I tried another way and got errors,
also am with this approach. Googling turns up more people with same problem, but no solution. This works under my login. I try under another login and it fails. In the other login, I can open the PST and read it, add to it, delete from it, etc., but this will not work programmatically. The kicker is that the similar code works fine under VB6 using the same PST source and destination and same login. In the following code, I get the error at the "Folders.Add" that it cannot create the folder. The source is a normal PST. The destination is a shell or template that has only Deleted Items and Search Folders. This folder is supposed to create the appropriate folder. Any ideas? If not, it's VB6 for this puppy. --- Public Function CopyMailFromReferenceToTarget(ByVal uniqueMailId As String) 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 Select Case itemParent.DefaultItemType Case 9 _targetMailDatabase.Folders.Add(itemParent.Name, Outlook.OlDefaultFolders.olFolderCalendar) Case 10 _targetMailDatabase.Folders.Add(itemParent.Name, Outlook.OlDefaultFolders.olFolderContacts) Case 13 _targetMailDatabase.Folders.Add(itemParent.Name, Outlook.OlDefaultFolders.olFolderTasks) Case 11 _targetMailDatabase.Folders.Add(itemParent.Name, Outlook.OlDefaultFolders.olFolderJournal) Case 12 _targetMailDatabase.Folders.Add(itemParent.Name, Outlook.OlDefaultFolders.olFolderNotes) Case 6 _targetMailDatabase.Folders.Add(itemParent.Name, Outlook.OlDefaultFolders.olFolderInbox) Case 16 _targetMailDatabase.Folders.Add(itemParent.Name, Outlook.OlDefaultFolders.olFolderDrafts) Case Else _targetMailDatabase.Folders.Add(itemParent.Name) End Select copyFolder = GetFolder(itemParent.FolderPath, _targetMailDatabase) '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 --- |
All times are GMT +1. The time now is 11:45 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com