I am accessing Lotus Notes via OLE, and this is how I retrieve the selected mail:
try
UIView := FLNotes.CURRENTVIEW; // am I in a view or in an opened document ?
if VarIsClear(UIView) then begin
try
aDocument := FLNotes.CURRENTDOCUMENT.Document;
except
raise;
end;
end else begin // any selected mails in view ?
UIDocuments := UIView.DOCUMENTS;
for counter := 1 to UIDocuments.Count do begin
if counter = 1 Then
aDocument := UIDocuments.GETFIRSTDOCUMENT
else
aDocument := UIDocuments.GETNEXTDOCUMENT(aDocument);
end;
end;
finally
UIView := Unassigned;
UIDocuments := Unassigned;
aDocument := Unassigned;
end;
I have the reference to the particular mail in aDocument
. Now I would like to save every each mail (on the disk as a file, not inside Lotus Notes), but I didnt find the right method to use with OLE.
I have found this Notes Commands, but I didnt figure out whats the syntax for OLE access. I tried it like this: aDocument.Command("FileSave", "Test.eml")
, and I tried also lot of other combinations with Save
but none of them worked. So maybe somebody did this already or has a tip where I could look for a solution
Thanks Regards
It seems that there is a way to save the mail as an eml file (actually any file that you want, but since .eml is what I need I will use that). So for any case somebody may need it here the code :
try
oleSession := GetActiveOleObject('Notes.NotesSession');
except
oleSession := CreateOleObject('Notes.NotesSession');
end;
path := '...Somepath.../Mail.eml';
oleDB := oleSession.CurrentDatabase;
oleSession.ConvertMIME := false;
oleView := GetSelectedMail; //the code for this is in the first post
oleDoc := oleView.GetFirstDocument;
oleDoc.converttomime(1);
mime := oleDoc.getmimeentity;
oleEmailText := oleSession.CreateStream; // create a stream to fill it with the data
oleEmailText.open(path, 'us-ascii');
mime.GetEntityAsText(oleEmailText); // write inside stream
oleSession.ConvertMIME := true; // put this flag back to its original state - per default its true -
Just as a side note, with this method attachments are missing from the saved mail. But since I separate them and save inside another folder, its not a big issue for my case
Regards