F
Frode Lillerud
Hello,
I'm trying to do some simple folder manipulation.
I'm able to create a folder, but I'm having some problems getting the code
to find it again the next time the program starts.
Right now I'm writing some code that for-loops through all the folder using
the .GetNext()-method, and checks whether the .Name-property is the one I'm
looking for.
The problem is that the .GetNext()-method always returns the __second__
folder, and doesn't iterate further.
For instance, having the following four folders: Folder1, Folder2, Folder3
and Folder4.
..GetFirst() always returns Folder 1
..GetNext() always returns Folder2
and
..GetLast() always returns Folder4
Here is a fragment of the code (in C#):
Outlook.MAPIFolder oInbox = olNameSpace.GetDefaultFolder
(Outlook.OlDefaultFolders.olFolderInbox);
oSWFolder = oInbox.Folders.GetFirst();
for (int counter = 1; Counter <= iTotalNumberOfFolders; counter++)
{
if (oSWFolder.Name == "MyFolder")
{
iSWFolderNumber = teller;
break;
}
else
{
oSWFolder = oInbox.Folders.GetNext();
}
}
Can anyone explain why I'm not able to get to Folder3??
and second question:
On a MSDN page I've read about a .Item(int) property
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/
_olemsg_item_property_folders_collection_.asp), but there doesn't seem to
be one available to me.
How can I fast and easily select the folder when I know which number it
has? Like the iSWFolderNumber in the preceding code.
Thanks
I'm trying to do some simple folder manipulation.
I'm able to create a folder, but I'm having some problems getting the code
to find it again the next time the program starts.
Right now I'm writing some code that for-loops through all the folder using
the .GetNext()-method, and checks whether the .Name-property is the one I'm
looking for.
The problem is that the .GetNext()-method always returns the __second__
folder, and doesn't iterate further.
For instance, having the following four folders: Folder1, Folder2, Folder3
and Folder4.
..GetFirst() always returns Folder 1
..GetNext() always returns Folder2
and
..GetLast() always returns Folder4
Here is a fragment of the code (in C#):
Outlook.MAPIFolder oInbox = olNameSpace.GetDefaultFolder
(Outlook.OlDefaultFolders.olFolderInbox);
oSWFolder = oInbox.Folders.GetFirst();
for (int counter = 1; Counter <= iTotalNumberOfFolders; counter++)
{
if (oSWFolder.Name == "MyFolder")
{
iSWFolderNumber = teller;
break;
}
else
{
oSWFolder = oInbox.Folders.GetNext();
}
}
Can anyone explain why I'm not able to get to Folder3??
and second question:
On a MSDN page I've read about a .Item(int) property
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/
_olemsg_item_property_folders_collection_.asp), but there doesn't seem to
be one available to me.
How can I fast and easily select the folder when I know which number it
has? Like the iSWFolderNumber in the preceding code.
Thanks