0
在Java代理中,我生成一封郵件。當我只用文本發送郵件時,郵件會發送給收件人。我也想附加一個XML文件到郵件。如果我附上它,我的筆記服務器崩潰。將xml文件附加到mimeentity崩潰Notes服務器
我覺得我的代碼是錯誤的,這就是我想要的附件添加到郵件的部分:
mime = mimeRoot.createChildEntity();
MIMEHeader hdr = mime.createHeader("Content-Disposition");
hdr.setHeaderValAndParams("attachment; filename=" + OrderFilePath);
Stream stream = session.createStream();
System.out.println("Open stream");
//AT THIS IF IT WILL CRASH THE SERVER
if (stream.open(OrderFilePath, "binary")){
System.out.println("in eerste if");
if (stream.getBytes() != 0) {
System.out.println("getbytes !0 ");
mime.setContentFromBytes(stream, "application/octet-stream",MIMEEntity.ENC_IDENTITY_BINARY);
}
else System.out.println
(OrderFilePath + "has no content or is not working");
}
文件有多大? –
不大10kb大約 – YdB
你有從服務器崩潰的NSD文件嗎? –