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
REM
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.Type = EMBED_ATTACHMENT) Then
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
Else
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 =
replaceDoc.ReplaceItemValue("Subject",doc.Subject)
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 =
replaceDoc.ReplaceItemValue("BlindCopyTo",doc.BlindCopyTo)
Set item =
replaceDoc.ReplaceItemValue("DefaultMailSaveOptions",doc.DefaultMailSaveOptions)
Set item = replaceDoc.ReplaceItemValue("Logo",doc.Logo)
Set item =
replaceDoc.ReplaceItemValue("MailSaveOptions",doc.MailSaveOptions)
Set item =
replaceDoc.ReplaceItemValue("COUNTED",doc.COUNTED)
Set item =
replaceDoc.ReplaceItemValue("IPNotify",doc.IPNotify)
Set item =
replaceDoc.ReplaceItemValue("DeliveredDate",doc.DeliveredDate)
Set item =
replaceDoc.ReplaceItemValue("Categories",doc.Categories)
Set item =
replaceDoc.ReplaceItemValue("RouteTimes",doc.RouteTimes)
Set item =
replaceDoc.ReplaceItemValue("RouteServers",doc.RouteServers)
Set item =
replaceDoc.ReplaceItemValue("PostedDate",doc.PostedDate)
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
Next
Print "....agent ends"
End Sub

This was first published in November 2000

Dig deeper on Domino Resources - Part 2

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

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 ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close