Manage Learn to apply best practices and optimize your operations.

C.Dtf "Phantom Attachment" Strip Code

If you have an older version of Notes (like 4.6.3), and have an Email-In database to capture incoming emails, sometimes you may receive a bounced message along with a file attachment called C.DTF that can not be opened. Such documents can not be archived through agents normally because the attachment apparently does not exist and so the agent may crash. To prevent this, run this code to first strip out the phantom attachment.

Note: This example uses a daily scheduled agent that is set to run on "all new and unmodified documents since last run."

Note: Replace the field names at the bottom of the code as needed.

Sub Initialize
REM Strip Phantom Attachment C.DTF
On Error Resume Next
Dim rtitem As Variant,doc As NotesDocument,item As NotesItem
Dim session As New NotesSession,db As NotesDatabase
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Print "....agent starting"
REM Attempt to kill known types of phantom attachments
For i = 1 To collection.Count
Set doc = collection.GetNthDocument(i)
REM First attempt to strip phantom doc...
REM Old Phantom Strip Code
Set rtitem = doc.GetFirstItem("Body")
If (rtitem.Type = RICHTEXT) Then
Forall o In rtitem.EmbeddedObjects
If (o.Name ="C.DTF") Then
Call o.Remove
Call doc.Save(False,True)
End If
End If
End Forall
End If
REM Second, let's really make sure there's no phantom left....
REM New Phantom Strip Code (due to server changes)
myFile = doc.GetItemValue("$FILE")
If Isempty(myFile) Then
REM No file attached
REM Check for known phantom attachment name of C.DTF
If myFile(0) = "C.DTF" Then
Print "Found phantom attachment. File attached is ---> "
& myFile(0)
REM Copy Doc to new replaceDoc
Dim replaceDoc As New NotesDocument(db)
replaceDoc.Form = "Memo"
REM NOTE: Replace these field names as needed
Set item =
Set item = replaceDoc.ReplaceItemValue("From",doc.From)
Set item = replaceDoc.ReplaceItemValue("SendTo",doc.SendTo)
Set item = replaceDoc.ReplaceItemValue("Body",doc.Body)
Set item = replaceDoc.ReplaceItemValue("Owner",doc.Owner)
Set item = replaceDoc.ReplaceItemValue("CopyTo",doc.CopyTo)
Set item =
Set item =
Set item = replaceDoc.ReplaceItemValue("Logo",doc.Logo)
Set item =
Set item =
Set item =
Set item =
Set item =
Set item =
Set item =
Set item =
REM Mark this new doc for future reference that it was a phantom
Set item = replaceDoc.ReplaceItemValue("WasPhantom","true")
Call replaceDoc.Save(True,False)
REM Remove old doc
Call doc.remove(True)
End If
End If
Print "....agent ends"
End Sub

This was last published in November 2000

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.




  • iSeries tutorials'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 ...