+2  A: 

The short answer is Yes. The long answer is painful. There aren't any great classes exposed to manipulate rich text items in Notes. However a few that you can research are the NotesRichTextStyle, NotesRichTextParagraphStyle, and NotesRichTextTable to name a few. These classes help you define some rich text elements and add them programmatically to your rich text field.

Another approach, since you're sending email, is to use the NotesMIMEEntity classes and build the email using HTML (way way easier). Here's some sample code:

Set s = New NotesSession
Dim docMail As NotesDocument
Dim body As NotesMIMEEntity
Dim stream As NotesStream

Set db = s.CurrentDatabase
s.ConvertMIME = False ' Do not convert MIME to rich text

'Create email to be sent
Set docMail = db.CreateDocument

With docMail
     .SendTo = SEND TO ADDRESS
     .From = FROM ADDRESS
     .Principal = FROM ADDRESS
     .ReplyTo = REPLY TO ADDRESS
     .Subject = SUBJECT
     .Form = "Memo"
End With

  Set stream = s.CreateStream
Set body = docMail.CreateMIMEEntity
Call stream.WriteText ("YOUR HTML CODE GOES HERE")

'ENC_IDENTITY_8BIT used because of technote found on notes.net
'http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/aeedaf28e47546ad85256f6a000a4b48?OpenDocument
Call body.SetContentFromText (stream, "text/html;charset=iso-8859-1",ENC_IDENTITY_8BIT) 

Call docMail.Send(False)
Set docMail = Nothing
Set body = Nothing
Set stream = Nothing

s.ConvertMIME = True ' Restore conversion

Essentially you'll need to turn the ConvertMIME setting off in the NotesSession. Then create a new document, set the mail properties, etc. That part is already in your VBA code. Next, create the MIMEEntity and a stream to hold your HTML text. Finally call the SetContentFromText method on your MIMEEntity object. Then send your email. Note the last call is to turn the ConvertMIME feature back on for the NotesSession.

I'm not sure if this will all work via COM, but it does work well in LotusScript agents in Notes.

I hope this helps!

Ken Pespisa
Thanks, this seems about as easy as I'd imagined! I tried integrating your code into my project, but even after adding references to every Lotus Notes library I'm still running into problems. Chiefly, I don't think NotesStream is available via COM, which kinda puts the kibosh on the whole thing.
Lunatik
I checked the help file: There is no mention that stream isn't supported in COM, so it should work. You might want to cheat: Store the plain HTML into the field and then call an LotusScript agent on it that does the conversion for you.
stwissel
A: 

do you have any example like this using java ? I just need to send email using lotus notes from a java class.

Thanks and regards.

Please ask questions as questions.
Greg D
A: 

I would also be interested in a Java based solution!

A: 

I like it just the way it is. However, I had to change dbString = "mail\" & Application.UserName & ".nsf" to dbString = "mail\" & Application.CurrentUser & ".nsf"

First comment: I wish I didn't have to have Lotus Notes open at the time of sending.

Second comment: I wish I could change who the e-mail is from (ie, if I'm sending a report to 50 people, I want it to be from a generic address, rather than my work address)

Dan Newton
A: 

To change who it's from, create a generic Notes ID (eg Auto Send/YourCompany) and save the agent with that ID.

Greg
A: 

I found this page and this seems to be just what I was looking for, except for one thing: in my html page I have to put an image, by an img src tag. The image doesn't appear in the resulting Lotus mail. Is there some more code to add? regards, Riccardo Baldinotti, Italy

Riccardo Baldinotti