Examples: CloseMIMEEntities method

This agent changes a MIME header, closes MIME processing, and deletes the associated "Body" items. Closing MIME processing with the save option pushes the header change to the "Subject" item.

Sub Initialize
  Dim s As New NotesSession
  Dim db As NotesDatabase
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Dim mime As NotesMIMEEntity
  Dim header As NotesMIMEHeader
  Set db = s.CurrentDatabase
  s.ConvertMIME = False ' Do not convert MIME to rich text
  Set dc = db.UnprocessedDocuments
  Set doc = dc.GetFirstDocument
  If Not(doc Is Nothing) Then
    Set mime = doc.GetMIMEEntity
    If Not(mime Is Nothing) Then
      Set header = mime.GetNthHeader("Subject")
      Call header.SetHeaderVal(header.GetHeaderVal() & _
      " - Body removed")
      If doc.CloseMIMEEntities(True, "Body") Then
        Call doc.RemoveItem("Body")
      End If
      Call doc.Save(True, True)
      Messagebox "Not MIME",, doc.GetItemValue("Subject")(0)
    End If
  End If
  s.ConvertMIME = True ' Restore MIME conversion
End Sub