You Can View User Feedback To This Tip
You only need to modify the "Reply" and the "Reply With
History" forms. They way we've done it is simple, and it works. Try it out.
Here's the code for the "Reply With History" form, put
it in the "Postopen" event (below the: "Call cMemoObject.PostOpen(Source)"
code):
Code
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim doc As NotesDocument
Dim id As String
id = session.GetEnvironmentString("DeleteAttachment")
If id <> "" Then
On Error Goto finish
Set doc = db.GetDocumentByUNID(id)
If Not doc Is Nothing Then
Call doc.Remove(True)
End If
Call session.SetEnvironmentVar("DeleteAttachment", "")
End If
finish:
'Remove attachments - if any
Set doc = Source.Document
If doc.HasEmbedded = True Then
response= Msgbox("Shall I remove attachments from your answer?",
32+4, "Reply with attachments")
If response = 7 Then
'Mail with attachments
Exit Sub
End If
Else
'No attachments
Exit Sub
End If
'Here we remove attachments
Call Source.Save
Dim item As NotesRichTextItem
Set item = doc.getFirstItem("Body")
Forall o In item.EmbeddedObjects
If (o.Type = EMBED_ATTACHMENT) Then
'And write the name on the removed files
Call item.Appendtext("<< Attachment removed : " + o.Source + " >>")
Call item.AddNewLine(1)
Call o.Remove
Call doc.Save(1,0,1)
End If
End Forall
Call Source.Close
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.EditDocument(True, doc)
Call session.SetEnvironmentVar("DeleteAttachment", doc.UniversalID, False)
We use the "Reply" form for the respons without attachment, here's the code for the "Postopen" event in that form:
'Remove doc's that have been saved earlier
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim doc As NotesDocument
Dim id As String
id = session.GetEnvironmentString("DeleteAttachment")
If id <> "" Then
On Error Goto finish
Set doc = db.GetDocumentByUNID(id)
If Not doc Is Nothing Then
Call doc.Remove(True)
End If
Call session.SetEnvironmentVar("DeleteAttachment", "")
End If
Exit Sub
finish:
Exit Sub
End Sub
USER FEEDBACK TO THIS TIP
- It works, however it shows an error after you say yes to the prompt if you want to remove attachments. The error occurs when you execute the Call Source.Save line, inside the Private Function SetOptionField(Itemname As String, nFlag As Integer) it stops with 'Object variable not set' error message on the following line: Case ITEM_REMOVE Jacek Sompel