13-08-19 02:50 PM
I have written a function to iterate through the folders in outlook to retrieve the sub folder and download the attachment. the recursion function has been written in global code stage of initialize page and the main program i calling the function. What i want to understand is whether the code stage acts as a main() function? if so, then it should invoke the function which it is not.
I have written the recursion in global code. MultipleID m = new MultipleID(); MultipleID is the name of the object.
//initialize page code:
public string folderPath =@'\abc@outlook.com est est1 est2';
public string subject ='test exist';
//path to save the attachment
public path =@'C: est';
public void ProcessFolder(MAPIFolder folder)
{
foreach(MAPIFolder subFolder in folder.Folders)
{
if(subFolder.FullFolderPath == folderPath)
{
}
}
ProcessFolder(subFolder);
}
//code stage
MultipleID m = new MultipleID();
string EmailID = 'abc@outlook.com';
Microsoft.Office.Interop.Outlook.Application app = new
Microsoft.Office.Interop.Outlook.Application();
Accounts acc = app.Session.Accounts;
NamesSpace ns = app.GetNamespace('MAPI');
Folder folder = app.Session.DefaultStore.GetRootFolder() as Folder;
Microsoft.Office.Interop.Outlook.Stores stores = ns.Stores;
foreach(Microsoft.Office.Interop.Outlook.Store store in stores)
{
if(store.DisplayName == EmailID)
{
MAPIFolder inbox_folder =
store.GetDefaultFolder(olDefaultFolders.OlFolderInbox);
m.ProcessFolder(inbox_folder);
}
}
--------------------------------------------------24-09-19 07:55 AM