Digital Exchange

Expand all | Collapse all

how to call a function from global stage to code stage?

  • 1.  how to call a function from global stage to code stage?

    Posted 08-13-2019 14:50

    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);
              }
         }    
    
    --------------------------------------------------
    Disclaimer: This content was auto-posted from Stackoverflow. The original Stackoverflow question is here Stackoverflow Post, posted by Ankita Mohapatra.


  • 2.  RE: how to call a function from global stage to code stage?

    Posted 09-24-2019 07:55
    Hello Ankita,

    Thank you for using Blue Prism and your question.

    The global stage acts as a kind of repository for your own code such as classes and methods. The idea being that your code can then call those routines in your own code stages. You say that your ProcessFolder method is not being called. Can I ask, is there any possibility that an exception is occurring before it is getting there? My thoughts are a possible stack overflow, given we are talking recursion here.

    My suggestion to you to assist in any debugging is to wrap a try-catch around your code and then add a temporary output text parameter to your code stage and catch the Exception.Message value, should there be one. This value can be assigned in the catch area.

    The other matter could possibly be a security issue that outlook is detecting it is being used outside of its own process and is perhaps protecting itself. This is only a suggestion and not a definate statement of what could be happening.

    I hope I have at least helped further your understanding of  the situation.

    Once again thank you for using Blue Prism and being part of the community.

    ------------------------------
    Geoff Hirst
    Partner Pre Sales
    Blue Prism
    ------------------------------