如何在项目文件夹中创建文本文件,我需要将此文件作为电子邮件附件发送。然后我需要删除这个文件。
var textBuffer="BEGIN:VCALENDAR\r\nVERSION:2.0\r\n...END:VEVENT\r\nEND:VCALENDAR";
file = new java.io.File("c:\\Notes\\sample.ics");
//Create the file
if (file.createNewFile()){
print("File is created!");
}
else{
print("File already exists.");
}
//Write Content
writer = new java.io.FileOutputStream(file);
writer.write(textBuffer.getBytes());
writer.close();
var db:Database = session.getDatabase("server name", "database name", false);
var doc:NotesDocument = database.createDocument();
doc.appendItemValue("Form", "Memo");
var nMime:NotesMIMEEntity = doc.createMIMEEntity();
var mimeHeader:NotesMIMEHeader;
mimeHeader = nMime.createHeader("To");
mimeHeader.setHeaderVal("email id");
mimeHeader = nMime.createHeader("Subject");
mimeHeader.addValText("Test Email", "UTF-8");
var stream:NotesStream = session.createStream();
var pathname:string = "c:\\Notes\\sample.ics";
if (stream.open(pathname, "binary")) {
nMime.getContentAsBytes(stream);
stream.close();
}
nMime.setContentFromBytes(stream, "text/plain; charset=\"UTF-8\"",NotesMIMEEntity.ENC_NONE);
doc.send();
session.setConvertMIME(true);
执行此代码后,我收到一封邮件,但没有附件。请帮我找出这段代码出了什么问题。