![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 --- |
Ads |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Russ Valentine MVP: Can you help with my Microsoft Outlook Contacts folder problem? | [email protected] | Outlook - General Queries | 5 | January 10th 06 11:56 PM |