gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 13:57:55 25 4
gpt4 key购买 nike

我通过编写java邮件发送程序通过Domino服务器发送电子邮件。以前我使用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() 一起使用来进行 key 加密。电子邮件使用公钥加密。

加密()方法的帮助说明

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 项),这会在保存已发送消息的副本时搞乱事情。

关于java - 无法通过 Domino 服务器查看通过 Java 程序发送的加密邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29629359/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com