Search code examples
javalotus-noteslotus-dominolotusscriptdomino-designer-eclipse

Lotus Domino restricted mail group creation


I am trying to create a mail group in lotus domino using notes api. I want to apply a restriction on group that only group members can send email to group. I am able to create group but the people those are not members of group are also able to send email to group. I am using simple java code.

class MyGroup
{
    public static void main(String args[])
    {
        Session session=NotesFactory.createSession(host, username, password);
        Database directory=session.getDatabase(host, "names.nsf");
        Document doc=directory.createDocument();
        doc.appendItemValue("Form", "Group");
        doc.appendItemValue("ListName", "mymailgroup");
        doc.appendItemValue("ListOwner", "akash");
        doc.appendItemValue("LocalAdmin", "administrator");
        doc.appendItemValue("InternetAddress", "[email protected]");
        doc.appendItemValue("ListDescription", "My mail group");
        doc.appendItemValue("Members", "");
        Item memberList=doc.getFirstItem("Members");
        memberList.appendToTextList("[email protected]");
        memberList.appendToTextList("[email protected]");
        doc.appendItemValue("GroupType", "1")
        doc.replaceItemValue("$Readers", "mymailgroup");
        doc.save();
    }
}

Solution

  • You need to make the $Readers a readers item. Just add the following lines before your save:

    Item readers = doc.replaceItemValue("$Readers", "mymailgroup");
    readers.setReaders(true);
    

    BUT: Like that NOBODY except the members see the group. You need to make the document visible to LocalDomainServers to make it addressable.

    And: ListOwner and LocalAdmin are author- items. You need to use setAuthors(true) on them as well to make them functional.