|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Adding a folder in inboxI want to check whether a folder named "processed emails" exists within the
user's inbox if not create that folder within the inbox. set Inbox = Application.Session.GetDefaultFolder(olFolderInbox)
on error resume next err.clear set SubFolder = Inbox.Folders("Whatever") if err.Number <> 0 Then err.Clear set SubFolder = Inbox.Folders.Add("Whatever") End If MsgBox TypeName(SubFolder) Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool Show quote "css" <c**@discussions.microsoft.com> wrote in message news:BF0D7D81-9BF0-4345-8324-7372CD48A5C1@microsoft.com... >I want to check whether a folder named "processed emails" exists within the > user's inbox if not create that folder within the inbox. > > Unfortunately, this will not work for me..
I am using VB 2005 and creating an outlook add-in using VSTO.. it is throwing an exception at line +++ +++Dim objNewFolder As Outlook.MAPIFolder = Inbox.Folders("Processed Items") If objNewFolder IS Not Nothing Then objNewfolder = Inbox.folders.add("Processed Item") End If This is what I finally come up with but is there a better solution?
I am creating a folder when an exception is thrown.... InBox = Me.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) 'If folder does not exist create a folder and within the inbox Dim objImagingFolder As Outlook.MAPIFolder Try objImagingFolder = InBox.Folders.Item("Imaged Items") Catch ex As Exception objImagingFolder = InBox.Folders.Add("Imaged Items") End Try And what does the exception say when you add a folder?
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool Show quote "css" <c**@discussions.microsoft.com> wrote in message news:C365D289-7032-4326-93AF-913AC628EED3@microsoft.com... > This is what I finally come up with but is there a better solution? > > I am creating a folder when an exception is thrown.... > > InBox = > Me.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) > > 'If folder does not exist create a folder and within the inbox > Dim objImagingFolder As Outlook.MAPIFolder > > Try > objImagingFolder = InBox.Folders.Item("Imaged Items") > Catch ex As Exception > objImagingFolder = InBox.Folders.Add("Imaged Items") > End Try > > Are you sure it is on the Folders.Add rather than Folders.Item line?
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool Show quote "css" <c**@discussions.microsoft.com> wrote in message news:783003D3-1843-4C24-84D8-6D4275C2BD37@microsoft.com... > The operation failed. An object could not be found > Dmitry, I sincerely apolgozie, this is not an organized communication on my
part the exception is on Folders.Item line Is there an alternative for checking whether a folder exist? I am not very familiar with outlook object model..how about GetFolderFromID? No, I don't think there is any other way of doing that in OOM.
GetFolderFromID won't work since you do not know the folder's entry id, and it is never related to the folder's name or path. Why using Folders.Item() is a problem? You get an exception, which you expect and handle appropriately. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool Show quote "css" <c**@discussions.microsoft.com> wrote in message news:A63A6F6D-8327-4789-9C43-0CD25846CBC9@microsoft.com... > Dmitry, I sincerely apolgozie, this is not an organized communication on > my > part > > the exception is on Folders.Item line > > Is there an alternative for checking whether a folder exist? I am not very > familiar with outlook object model..how about GetFolderFromID? |
|||||||||||||||||||||||