简体   繁体   English

无法通过Domino Sever通过Java程序查看Encyrpted发送邮件

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

I am sending email through Domino Server by writing java mail sender program. 我正在通过编写Java邮件发件人程序通过Domino服务器发送电子邮件。 Previously I was using notes dll but now I have switched to iiop. 以前我使用Notes dll,但现在我切换到了iiop。 Since then I am not able to see the content of my sent Encrypted mail . 从那时起,我无法看到已发送的加密邮件的内容。 The recepients can read the mail very well its just me. 收件人可以很好地阅读邮件,仅我自己。 But I should be able to see my sent Encrypted mail. 但是我应该能够看到我发送的加密邮件。

When I send email via Lotus Notes client then it works. 当我通过Lotus Notes客户端发送电子邮件时,它可以工作。 Did I forget to set anything in code or what? 我忘记设置任何代码吗?

Code used is below: 使用的代码如下:

 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();
        }

    }

Kindly let me know what I am missing. 请让我知道我在想什么。

Thanks 谢谢

You are calling both lDoc.setEncryptOnSend(true) and lDoc.encrypt(). 您同时调用了lDoc.setEncryptOnSend(true)和lDoc.encrypt()。 The encrypt() method is normally used with setEncryptionKeys() to do secret key encryption. 通常,crypto()方法与setEncryptionKeys()一起使用以进行秘密密钥加密。 Email uses public key encryption. 电子邮件使用公共密钥加密。

The help for the encrypt() method states crypto()方法状态的帮助

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. 而是将EncryptOnSend属性设置为True,并使用Send方法。

Try getting rid of the call to lDoc.encrypt(). 尝试摆脱对lDoc.encrypt()的调用。 My guess is that by calling it, you're changing something in the internal state of the document (maybe creating an empty SecretEncryptionKeys item) that is messing things up while saving your copy of the Sent message. 我的猜测是,通过调用它,您正在更改文档内部状态中的某些内容(可能创建了一个空的SecretEncryptionKeys项),这在保存“已发送”消息的副本时弄乱了内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM