Manage Learn to apply best practices and optimize your operations.

Remove attachment(s) from reply with history

This tip details how to remove attachements from e-mail replies with history.

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):
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

Dig Deeper on Domino Resources - Part 6

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close