Tip

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.