Previous Topic

Next Topic

Book Contents

Book Index

Create an e-mail containing an image

The following sample will be implemented as an LotusScript agent and is intended to be launched from a Notes view. Declare the ImportImage function as specified here, and enter the following code in the Initialize-section of the agent:

' First declare everything and set the current database

Dim lRc As Long

Dim session As New notessession

Dim doc As NotesDocument

Dim db As notesdatabase

Dim RtItem As NotesRichTextItem

Dim strUNID As String

Set db = session.CurrentDatabase

' Create a new document in the current database

Set doc = New NotesDocument(db)

doc.Form = "Memo"

doc.SendTo = "someuser@somecompany.com"

doc.Subject = "Here's the document you wanted"

Set RTItem = New NotesRichTextItem( doc, "Body")

Call doc.Save(True, False)

' Note that the document is saved, and the document unique ID is retrieved.

strUnid = doc.UniversalID

' Now, forget about the doc while ImportImage does its job

' Set the doc variable to Nothing while ImportImage do its job. This is the most important step here. Since II2LN always work on the backend document, the reference that the doc variable holds, will not be in sync with the modified document later on.

Set doc = Nothing

' Do the ImportImage job. You may wonder why you don't save the document after ImportImage? Remember, II2LN do this for you. All you need to now now, is open the document again.

lRc = ImportImage(db.Server,db.FilePath,strUnid,"Body","C:\ImageToSend.tif","SetLogFilename:c:\temp\temp.log;SetLogLevel:5;Resize:640,9999;LoadTIFFPage:0")

' Reconnect to the document, by retrieving the document by the unique id. This means that LotusScript will get the document again, and now the links within LotusScript are ok.

Set doc = db.GetDocumentByUNID(strUnid)

' Send and remove temporary document if you don't need it.

Call doc.Send(False)

Call doc.Remove(True)

See Also

Examples

Import an image from view context to the current document

Create a preview of PDF attachments