I don't know good solution for this task, so it would be cool if somebody share better way then this one.
So if you want to emulate editing of attachments via backend you can do next:
1. make edit button,.
- this button "Open attachment" should export attachment to disk and remember/save the path to the file somewhere.
Dim w As New NotesUIWorkspace
Dim s As New NotesSession
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim filename As String
Set doc = w.CurrentDocument.Document
Set rtitem = doc.GetFirstItem("Body")
If doc.HasEmbedded Then
Forall o In rtitem.EmbeddedObjects
filename = "c:\" & o.name
Call o.ExtractFile (filename)
Call doc.ReplaceItemValue("filename", filename)
Call ShellExecute(0, "Open", fileName,"", "C:\", 1)
End Forall
End If
than step #2
you should make some changes and save attachments
step #3
now we have to click on Import button, this button should remove old attachment and import new one. Something like this
Dim w As New NotesUIWorkspace
Dim s As New NotesSession
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim filename As String
Set doc = w.CurrentDocument.Document
Set rtitem = doc.GetFirstItem("Body")
If doc.HasEmbedded Then
Forall o In rtitem.EmbeddedObjects
filename = "c:\" & o.name
Call o.Remove()
Call rtitem.EmbedObject(EMBED_ATTACHMENT, "", doc.GetItemValue("filename")(0))
End Forall
End If
Call doc.ReplaceItemValue("filename", "")
Call doc.Save(True, True)
But if you read comments you will see much better solution, I should say that it is really good way to solve this task.
2 comments :
I use ClassAttachment class, found years ago in Lotus Sandbox.
I'm not sure if it works with all Windows OS, but surely with W2K and XP.
See it at http://www-10.lotus.com/ldd/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/8829cb697c74ab6d8525693700564486?OpenDocument
super! definitely it is what I was looking
Post a Comment