Scheinbar behandelt der Notes-Client geöffnete EML-Dateien aufgrund eines Feldes namens "EML" in dem angezeigten Dokument anders als andere Notes-interne Emails. Eine Möglichkeit geöffnete EML-Dateien zu importieren ist es daher, in der Standard-Email-Maske (Memo) eine Skript-Aktion zu erzeugen, die bei EML!>"1" verborgen wird, und aus dem geöffneten UI-Dokument ein neues Notes-Dokument erzeugt, das Feld "EML" entfernt und dass neue Dokument dann in einem Ordner ablegt, damit es auch gefunden werden kann.
Beispiel:
Sub Click(Source As Button)
' Diese Aktion speichert eine geöffnete EML-Datei in dem Ordner "EML-Import" ab
Dim session As New notessession
Dim db As NotesDatabase
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc, newDoc As NotesDocument
' geöffnetes EML-Dokument holen
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
' neues Dokument in DB anlegen und alle Felder des EML-Doks kopieren
Set db = session.CurrentDatabase
Set newDoc = db.CreateDocument
Call doc.Copyallitems(newDoc)
' Das Feld "EML" entfernen.
' Dadurch wird das Dokument wie ein normales Notes-Dokument behandelt
Call newDoc.removeItem("EML")
' Neues Dokument speichern und im Ordner ablegen
Call newDoc.save(True, False)
Call newDoc.putInFolder("EML-Import")
Call uidoc.Close
Messagebox "Das Dokument wurde im Ordner EML-Import gespeichert."
End Sub
Ok mal ganz Quick and Dirty implementiert müsste es ca. so gehen
// Wandelt eine Mail in ein eml File um.
public static void exportEMLFile(Document mail, File outFile) throws Exception {
Session ses = mail.getParentDatabase().getParent();
mail.removeItem("$KeepPrivate");
// Falls Mail kein Mime Mail dann konvertiere es. Die Konvertierung ist
// ähnlich fehlerbehaftet, wie wenn man das Mail nach Extern sendet.
if (mail.getMIMEEntity() == null)
mail.convertToMIME(Document.CVT_RT_TO_HTML);
MIMEEntity mE = null;
MIMEEntity mChild = null;
String contenttype = null;
String headers = null;
String content = null;
String preamble = null;
int encoding;
FileWriter output = null;
String noteid = mail.getNoteID();
int index;
// access document as mime parts
mE = mail.getMIMEEntity("Body");
output = new FileWriter(outFile);
((lotus.domino.MIMEHeader) mE.getHeaderObjects().get(0)).getHeaderValAndParams();
try {
contenttype = mE.getContentType();
headers = mE.getHeaders();
encoding = mE.getEncoding();
content = mE.getContentAsText();
// Falls nur ein Binäranhang, dann encode in Base64
if (content != null && content.trim().length() > 0 && encoding == MIMEEntity.ENC_IDENTITY_BINARY) {
mE.encodeContent(MIMEEntity.ENC_BASE64);
headers = mE.getHeaders(); // get again, because
// changed
content = mE.getContentAsText();
}
// message envelope. If no MIME-version header, add one
index = headers.indexOf("MIME-Version:");
if (index < 0)
output.write("MIME-Version: 1.0\n");
output.write(headers);
output.write("\n");
if (content != null && content.trim().length() > 0) {
output.write("\n");
output.write(content);
output.write("\n");
}
// For multipart, examine each child entity,
// re-code to base64 if necessary
if (contenttype.toLowerCase().startsWith("multipart")) {
processMultipart(mE, output);
} // end multipart
// end of main envelope
output.write(mE.getBoundaryEnd());
} finally {
if (output != null)
output.close();
}
}
private static void processMultipart(MIMEEntity mE, FileWriter output) throws NotesException, IOException {
MIMEEntity mChild;
String headers;
String content;
String preamble;
int encoding;
preamble = mE.getPreamble();
mChild = mE.getFirstChildEntity();
while (mChild != null) {
headers = mChild.getHeaders();
encoding = mChild.getEncoding();
// convert binary parts to base-64
if (encoding == MIMEEntity.ENC_IDENTITY_BINARY) {
mChild.encodeContent(MIMEEntity.ENC_BASE64);
headers = mChild.getHeaders(); // get again, because
// changed
}
preamble = mChild.getPreamble();
content = mChild.getBoundaryStart();
output.write(content);
if (!content.endsWith("\n"))
output.write("\n");
output.write(headers);
output.write("\n");
output.write("\n");
content = mChild.getContentAsText();
if (content != null && content.length() > 0)
output.write(content);
if (mChild.getContentType().toLowerCase().startsWith("multipart"))
processMultipart(mChild, output);
output.write(mChild.getBoundaryEnd());
mChild = mChild.getNextSibling();
}
}