Create a email attachment from a rich text field

81 Views Asked by At

I'd like to get content from a Lotus notes Rich Text field and put it into an email attachment and send it out. Don't want to inside the email body because it will be too much. Just want to be an attachment.

How can I do that in lotus notes script?

1

There are 1 best solutions below

0
Tode On

Unfortunately you can't do this with LotusScript easily at the moment. Technically this would be the creation of an EML file and attach it to the Body of an email OR printing it as PDF and then attach the PDF to the email. Although both features are available in newer Notes clients, they are both not "exposed" to LotusScript.

BUT: There are people that did this before and there is code out there to convert Mails to EML files with LotusScript.

You can download the example database from "Yuriy Pastovenskyy" from this link Or you can try the github code from here.

I did not test both of the solutions, so you need to find out yourself which one is matching your needs better.

You would then do something like this:

Dim ses as New NotesSession
Dim db as NotesDatabase
Dim docSource as NotesDocument
Dim docMemo as NotesDocument
Dim body as NotesRichtextItem
Dim emlPath as String

Set db = ses.CurrentDatabase
Set docSource = ....'somehow get the document that you want to export

emlPath = GetEmlFromDoc( docSource ) '- use Code from the links to export the docSource
Set docMemo = New NotesDocument( db )
Call docMemo.ReplaceitemValue( "Form" , "Memo" )
Set body = New NotesRichtextItem( docMemo, "Body" )
Call body.EmbedObject( EMBED_ATTACHMENT, "", empPath )
'- show the document for editing or send the mail here...

I know, that this is mainly a "link-only" answer, but the code is to complicated to post excerpts from one of the links here.