Previous Topic

Next Topic

Book Contents

Book Index

Import an image from view context to the current document

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 session As New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase

Dim lRc As Long

Dim strFileName As String

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim ws As New NotesUIWorkspace

' Ask the user for an image filename. Just accept one filename

filenames = ws.OpenFileDialog( False, _

"Image to be imported","All files|*.*|Jpegs|*.jpg",_

"c:\temp")

If Not(Isempty(filenames)) Then

Forall filename In filenames

strFileName = filename

Exit Forall

End Forall

End If

If strFileName <> "" Then

' Set up a collection of the UnprocessedDocuments, ie. work only with the selected Notes documen

Set collection = db.UnprocessedDocuments

Set doc = collection.GetFirstDocument()

While Not(doc Is Nothing)

// Perform the ImportImage function with the import option ReplaceWithVariable and Resize

lRc = ImportImage(_

db.Server,_

db.FilePath,_

doc.UniversalID, _

"Body",_

strFileName,_

"ReplaceWithVariable:$(Image);Resize:640,480")

Set doc = Nothing

' Don't bother to process more than one selected Notes document

exit while

Wend

End If

See Also

Examples

Create an e-mail containing an image

Create a preview of PDF attachments