A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - General Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Cannot Create Folder -- VB.NET



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 10th 06, 01:50 AM posted to microsoft.public.outlook
Randy Given
external usenet poster
 
Posts: 1
Default 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

---


Ads
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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 10:56 PM


All times are GMT +1. The time now is 01:02 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.