There seems to be several solutions:
- through OLE automation (I found very poor doc about OLE precisely, but the
doc about scripts is good and should suit);
- through the Notes API DLLs, but this needs a lot of DLLs to be in the
app's search path;
- using smtp (but this needs the notes server to be configured for it);
- buying some library (such as DNotes or IDSMail), but this needs paying;
- I heard some people saying Notes mail can be sent using MAPI, but did not
find anything about this.
I chose OLE automation because it does not need any DLL, and it is free
(well, it takes me a lot of time to understand).
Here is the simplest working example to send a Notes mail from a Delphi
program (I give it so that people who try to use Notes can start with a
simple example).
procedure TForm1.Button1Click(Sender: TObject);
var
Session: NotesSession;
DataBase: NotesDataBase;
Mail: NotesDocument;
begin
Session:= CreateOleObject('Notes.NotesSession') as NotesSession;
DataBase:= Session.GETDATABASE('', '');
DataBase.OpenMail;
Mail:= DataBase.CreateDocument;
Mail.AppendItemValue('Subject', 'Test - ignore');
Mail.AppendItemValue('Body', 'This is the body of the message');
Mail.Send(0, 'Vincent MAHON/marc-sgop/fr/socgen@SOCGEN');
end;
This example is OK to send a simple mail. The next step was to attach a file
to this mail.
All the documentation I read about Lotus Notes said that the body of the
mail is a NotesRichTextItem, and that this is what allows attaching a file
to a mail.
With the example above, I have two reasons to think that the body is not a
NotesRichTextItem:
1. When I receive the mail and look at the "document properties", it says
that the body is of type Text (while for emails I send from Notes, the body
is of type "rich text")
2. When I use GetFirstItem('Body'), the result I get is a NotesItem but not
a NotesRichTextItem.
Question: does anybody know why the body is not a NotesRichTextItem or how I
can attach a file to a mail I send from a Delphi program ?
Any comment welcome !
Thanks,
Vincent Mahon
Société Générale R&D, Paris
Vincen...@socgen.com
The Body field in your example takes a Text datatype because that is the
only type of value assigned to it in your code. In order to create the Body
field as rich text, you must specifically create a rich text field in the
document.
var
rtitem: NotesRichTextItem;
.
[create Mail object]
.
rtitem:= Mail.CreateRichTextItem("Body");
rtitem.AppendText('This is the body of the message');
I believe this will correctly create the Body field as a rich text field,
although I am not a Delphi programmer, only LotusScript and VB.
Regards,
Jack
Vincent MAHON wrote in message <711uq8$qml$1...@platane.wanadoo.fr>...
Below is some VB Code from Microsoft Access.
It creates a Mail Memo in Notes and attaches a file in the Body of the
Message.
The trick was in the:
Call notesrichtextitem.EmbedObject(1454, "", "c:\filename.txt")
The 1454 is the integer that Notes assigns instead of using
Embed_Attachment.
---CODE---
Dim session As Object
Dim notesdb
Dim doc
Dim YN
Dim notesrichtextitem
Set session = CreateObject("Notes.NotesSession")
Set notesdb = session.getdatabase("Server", "mail\Mailfile.nsf")
If Not notesdb.isopen Then
YN = notesdb.Open("Server", "mail\Mailfile.nsf")
End If
Set doc = notesdb.CREATEDOCUMENT()
Set notesrichtextitem = doc.CreateRichTextItem("BODY")
doc.Form = "Memo"
doc.sendto = "Recipient Name"
doc.CopyTo = "CC Name"
doc.Subject = "Subject"
doc.FROM = session.commonusername
doc.posteddate = Date
Call notesrichtextitem.EmbedObject(1454, "", "c:\filename.txt")
Call doc.Send(False)
doc.Save True, True
Have a nice day and enjoy Delphi programming.
Godinas-Andrien Alain
ADD-X Computers Belgium
agodinas...@addx.be
Vincent Mahon
Société Générale R&D, Paris
Vincen...@socgen.com
Jean-Michel Willette wrote in message <3638410D...@addx.be>...