'1. Import Image Resource: Option Public Option Declare Use "base64.lss" Sub Initialize Dim session As New NotesSession Dim ws As New NotesUIWorkspace Dim db As NotesDatabase Dim importer As NotesDXLImporter Dim stream As NotesStream Dim filename As String, head$, foot$, imageName$, imageType$ Dim imageFile As Variant, imgData As Variant Dim duplicateImageCheck As Boolean, ans As Integer imageFile = ws.OpenFileDialog( False , "Choose an image to import", "JPG Images|*.jpg|GIF Images|*.gif", "C:\") If Isempty(imageFile) Then Msgbox "You must select an image to continue. Please try again." Else Set db = session.CurrentDatabase imageName$ = Strrightback(imageFile(0), "\") imageType$ = Strrightback(imageFile(0), ".") If imageType$ = "jpg" Or imageType$ = "JPG" Then imageType$ = "jpeg" duplicateImageCheck = checkForDuplicates(db, imageName$) 'add code to handle what happens on a match If duplicateImageCheck Then ans = Messagebox("An image with that name already exists. Do you want to replace it?", 36, "Duplicate Image") If ans = 7 Then imageName$ = Inputbox("Please enter the new name for this image.", "Enter New Name", imageName$) End If End If 'write header head$ = ||&_ ||&_ ||&_ |<| & imageType$ & |>| imgData = Freefile Open imageFile(0) & ".xml" For Output As imgData Print #imgData, head$ Close #imgData 'append encoded image data Call EncodeFile(imageFile(0), imageFile(0) & ".xml") 'append footer foot$ = || imgData = Freefile Open imageFile(0) & ".xml" For Append As imgData Print #imgData, foot$ Close #imgData ' Open the newly created dxl file Set stream = session.CreateStream filename = imageFile(0) & ".xml" If Not stream.Open(filename) Then Messagebox "Cannot open " & filename,, "Error" Exit Sub End If If stream.Bytes = 0 Then Messagebox "File did not exist or was empty",, filename Exit Sub End If ' Import the DXL in "create" mode - replaces existing images Set importer = session.CreateDXLImporter ' On Error Goto errh Call importer.SetInput(stream) Call importer.SetOutput(db) importer.DesignImportOption = DXLIMPORTOPTION_REPLACE_ELSE_CREATE Call importer.Process Call stream.Close Kill imageFile(0) & ".xml" End If Goto done errh: Msgbox importer.Log Resume done done: End Sub Function checkForDuplicates(db As notesdatabase, imageName As String) Dim match As Boolean, nc As NotesNoteCollection, nid As String, nextid As String, ddoc As NotesDocument, i As Integer, resTitle As String match = False 'Create note collection of image resources to see if any have the same name as the current one Set nc = db.CreateNoteCollection(False) nc.SelectImageResources = True Call nc.BuildCollection nid = nc.GetFirstNoteId For i = 1 To nc.count 'get the next note ID before processing nextid = nc.GetNextNoteId(nid) Set ddoc = db.GetDocumentByID(nid) resTitle = ddoc.GetItemValue("$Title")(0) If resTitle = imageName$ Then match = True Exit For Else ' Msgbox "no match" End If nid = nextid Next checkForDuplicates = match End Function