Examples: DecodeContent method

This agent changes the encoding for a one-part MIME entity. If the entity content is already encoded (base64 or quoted-printable), the agent first decodes the entity.

Sub Initialize
  Dim ws As New NotesUIWorkspace
  Dim s As New NotesSession
  Dim db As NotesDatabase
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Dim mime As NotesMIMEEntity
  Dim mm(ENC_NONE To ENC_EXTENSION) As String
  mm(ENC_BASE64) = "base64"
  mm(ENC_EXTENSION) = "Extension"
  mm(ENC_IDENTITY_7BIT) = "7bit"
  mm(ENC_IDENTITY_8BIT) = "8bit"
  mm(ENC_IDENTITY_BINARY) = "binary"
  mm(ENC_NONE) = "None"
  mm(ENC_QUOTED_PRINTABLE) = "quoted-printable"
  Set db = s.CurrentDatabase
  s.ConvertMIME = False ' Do not convert MIME to rich text
  Set dc = db.UnprocessedDocuments
  Set doc = dc.GetFirstDocument
  While Not(doc Is Nothing)
    Set mime = doc.GetMIMEEntity
    If Not(mime Is Nothing) Then
     Call mime.DecodeContent
     m = ws.Prompt(PROMPT_OKCANCELLIST, _
      "Encoding", _
      "How do you want to encode this MIME entity?", _
      "quoted-printable", mm)
      If m = "" Then Goto ExitSub
      For n = ENC_NONE To ENC_EXTENSION
        If m = mm(n) Then
          Call mime.EncodeContent(n)
          Exit For
        End If
      Next
    Else
      Messagebox "Not processed",, "Not MIME"
    End If
    Call doc.Save(True, True)
    Set doc = dc.GetNextDocument(doc)
  Wend
ExitSub:
 s.ConvertMIME = True ' Restore conversion
End Sub