November 20, 200718 yr Requirements: ScriptMaster for FMP (AWESOME!) Install Groovy and Reboot (yes you have to reboot, the ActiveXProxy won't work without it) (During setup ActiveXProxy is an option, make sure it installs with Groovy.) Recommended: Install Advanced Security for Outlook Should be in a startup script: (if this runs more than once, it stops working!) SMLoadJar ( "file://C:/Program Files/Groovy/lib/scriptom-1.2.jar" ) & SMLoadJar ( "file://C:/Program Files/Groovy/lib/jacob.jar" ) Returns the Number of Contacts, followed by the Type and Name of each Item: EvaluateGroovy ( " import org.codehaus.groovy.scriptom.ActiveXProxy; // Create the Outlook Object def oOutlook = new ActiveXProxy("Outlook.Application"); //Logon to MAPI def oMAPI = oOutlook.GetNamespace("MAPI"); oMAPI.Logon "Outlook"; //Create the Contact Items Object def oContacts = oMAPI.GetDefaultFolder(10).Items; //Get the Number of Contact Items NumContacts = oContacts.Count.value; res = NumContacts + " Contacts Found"; //Loop through the Contact Items for (i in 1..NumContacts) { //Create the Contact Object def oContact = oContacts.Item(i); //Get the MessageClass of the Item def msgclass = oContact.MessageClass.value; if (msgclass == "IPM.Contact") { //If it is a Contact, do this res = res + "n" + msgclass + "tt" + oContact.FullName.value; } else if (msgclass == "IPM.DistList") { //If if is a Distribution List, do this res = res + "n" + msgclass + "t>>>t" + oContact.DLName.value; } else { //Otherwise, do this res = res + "n" + msgclass + "ttCANNOT HANDLE THIS CLASS"; } } //Return the results we've gathered return res; " ) Notice: When working with COM objects in Groovy you often have to use '.value' to get the value of a property. If you don't, the Object Handle can be passed rather that the data you are expecting.
Create an account or sign in to comment