Search code examples
vb.netcomlotus-noteslotus-dominolotus

Can't Create NotesUIWorkspace, howto


im trying to create the object NotesUIWorkspace to open the Maildialog from an Lotus Note Client V9 (add attachmen, text, recipents, ec) but it doesn't work I'm searching for the reference for NotesUIWorkspace, (i don't find it)

dim obj as Object
obj = CreateObject("Notes.NotesUIWorkspace") 

The Class i'm Trying to use https://notes.helsinki.fi/help/help8_designer.nsf/2e73cbb2141acefa85256b8700688cea/027a2bc771e3cb6e8525731b004a77f6?OpenDocument#183993280029220079
from the Documentation https://notes.helsinki.fi/help/help8_designer.nsf/Main?OpenFrameSet

I have searched for some examples but i didn't find any usefull for my expirience level.
Does anybody have some usefull tipps or examples?

Best Regards Florian


Solution

  • Here is an example using C# that will compose a memo in the UI:

    public void ComposeMemo(String sendto, String subject, String body)
            {
                // instantiate a Notes session and workspace
                Type NotesSession = Type.GetTypeFromProgID("Notes.NotesSession");
                Type NotesUIWorkspace = Type.GetTypeFromProgID("Notes.NotesUIWorkspace");
                Object sess = Activator.CreateInstance(NotesSession);
                Object ws = Activator.CreateInstance(NotesUIWorkspace);
    
                // open current user's mail file
                String mailServer = (String)NotesSession.InvokeMember("GetEnvironmentString", BindingFlags.InvokeMethod, null, sess, new Object[] { "MailServer", true });
                String mailFile = (String)NotesSession.InvokeMember("GetEnvironmentString", BindingFlags.InvokeMethod, null, sess, new Object[] { "MailFile", true });
                NotesUIWorkspace.InvokeMember("OpenDatabase", BindingFlags.InvokeMethod, null, ws, new Object[] { mailServer, mailFile });
                Object uidb = NotesUIWorkspace.InvokeMember("GetCurrentDatabase", BindingFlags.InvokeMethod, null, ws, null);
                Object db = NotesUIWorkspace.InvokeMember("Database", BindingFlags.GetProperty, null, uidb, null);
                Type NotesDatabase = db.GetType();
    
                // compose a new memo
                Object uidoc = NotesUIWorkspace.InvokeMember("ComposeDocument", BindingFlags.InvokeMethod, null, ws, new Object[] { mailServer, mailFile, "Memo", 0, 0, true });
                Type NotesUIDocument = uidoc.GetType();
                NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "EnterSendTo", sendto });
                NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "Subject", subject });
                NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "Body", body });
    
                // bring the Notes window to the front
                String windowTitle = (String)NotesUIDocument.InvokeMember("WindowTitle", BindingFlags.GetProperty, null, uidoc, null);
                Interaction.AppActivate(windowTitle);
            }