Domino Code Fragment

Code Name*
Working with Embedded Objects and Environment Variables
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.118.150.80
Description*
Working with Embedded Objects and Environment Variables
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
Exercise Title : Working with Embedded Objects and Environment Variables

Where : Button

Solution :

Sub Click(Source As Button)

'-- Get Front and Backend Document
Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument
Set uidoc = ws.currentdocument

Dim doc As NotesDocument
Set doc = UIDoc.document

'-- If new document then exit sub
If doc.IsNewNote Then Exit Sub

'-- Create Session object to access Notes.ini "Directory" value
Dim Session As New NotesSession
Dim dirpath As String
dirpath = session.GetEnvironmentString( "Directory", True )

'-- Loop through all attachments in document and detach to Notes Data Directory
Dim rtitem As Variant
Set rtitem = doc.GetFirstItem( "Body" )

'-- if array of embedded objects exist then detach all attachments into the Notes Data directory
If Isarray( rtitem.EmbeddedObjects ) Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
fullpath$ = dirpath + "\PGN2\ODBC\" + o.source

Messagebox(fullpath$)
Call o.ExtractFile( fullpath$ )
End If
End Forall
End If

End Sub