无法通过 Domino 服务器通过 Java 程序查看加密的已发送邮件

Not able to See Encyrpted Sent Mail via Java Program through Domino Sever

我正在通过编写 java 邮件发送程序通过 Domino Server 发送电子邮件。 以前我使用的是 notes dll,但现在我已经切换到 iiop。从那时起,我就看不到我 发送的加密邮件 的内容了。收件人可以很好地阅读邮件,只有我一个人。但是我应该可以看到我发送的加密邮件。

当我通过 Lotus Notes 客户端发送电子邮件时,它就可以工作了。 是我忘了在代码中设置什么吗?

使用的代码如下:

 public boolean sendMail(boolean schedule, String subject, String body, List<String> recipients, boolean doEncryt, boolean html, List<Binary> binaries, List<String> cc, List<String> bcc, List<String> replyTo)
    {

        String errorTxt = "";

        boolean diiop = true;
        try 
        { 
            Session session = null;
            // if (diiop)
            try {
                session = NotesFactory.createSession(NOTESMAILSERVER,"SOMEID",NOTESIDPW);
                diiop = true;
            }
            // else
            catch (Exception exc){
                NotesThread.sinitThread();
                session = NotesFactory.createSession();
                Registration lRegistration = session.createRegistration();
                lRegistration.switchToID(ResourceHelper.findResource(NOTESIDPATH).getFile().getAbsolutePath(), NOTESIDPW);
                diiop = false;
            }


            DbDirectory dir = session.getDbDirectory(NOTESMAILSERVER);
            Database    lDb = dir.openMailDatabase();

            session.setConvertMime(true);
            session.setConvertMIME(true);
            Document lDoc = lDb.createDocument();

            lDoc.replaceItemValue("Form"    ,"Memo");

            //set receip email addresses
            fillAdressItem(lDoc, recipients, "SendTo");
            fillAdressItem(lDoc, cc, "CopyTo");
            fillAdressItem(lDoc, bcc, "BlindCopyTo");

            //set subject
            lDoc.replaceItemValue("Subject" , subject);

            //set sender
            lDoc.replaceItemValue("From", this.FROM);
            lDoc.replaceItemValue("Principal", this.FROM);

            //prepare body text
            prepareRichTextBody(body, html, session, lDoc);

            //handle attachments
            RichTextItem lAttachmentItem = lDoc.createRichTextItem("attachments");

            if(binaries != null)
            {
                for(Binary binary : binaries)
                {

                    File tempFile = new File(getTempFolder(),binary.getName());
                    IOUtils.copyLarge(binary.getDataInputStream(), new FileOutputStream(tempFile));

                    lAttachmentItem.embedObject(EmbeddedObject.EMBED_ATTACHMENT, "", tempFile.getPath(), tempFile.getName());

                    tempFile.delete();
                }
            }

            //save if aSaveOnSend is true
            lDoc.setSaveMessageOnSend(true);

            //encrypt document if requested            
            if(doEncryt)
            {
                lDoc.setEncryptOnSend(true);
                lDoc.encrypt();
            }

            //send mail
            lDoc.send();

            return(true);
        } 
        catch(Throwable lE) 
        {

        }
        finally
        {
            if (!diiop) NotesThread.stermThread();
        }

    }

请让我知道我缺少什么。

谢谢

您正在调用 lDoc.setEncryptOnSend(true) 和 lDoc.encrypt()。 encrypt() 方法通常与 setEncryptionKeys() 一起使用以进行密钥加密。电子邮件使用 public 密钥加密。

encrypt() 方法的帮助说明

Since mail encryption works differently, don't use this method if you want to mail an encrypted document. Instead, set the EncryptOnSend property to True, and use the Send method.

尝试摆脱对 lDoc.encrypt() 的调用。我的猜测是,通过调用它,您正在更改文档内部状态中的某些内容(可能创建一个空的 SecretEncryptionKeys 项),这在保存已发送消息的副本时会把事情搞砸。