Sample code for 30+ languages & platforms
PowerBuilder

Remove a MIME Header Field

See more MIME Examples

Demonstrates the Chilkat Mime.RemoveHeaderField method, which removes header fields whose name matches case-insensitively. The first argument is the field name and the second (bAllOccurrences) selects whether to remove all matches or only the first. It is a void method.

Note: The file path is relative to the application's current working directory. Absolute paths may also be used. Supply the path to your own file.

Background: Stripping headers is common when reprocessing a message — removing spam-scoring X- headers, clearing an old Content-Length before re-serializing, or deleting routing headers before forwarding. The all-occurrences flag matters for headers that can repeat: pass true to purge every instance, or false to drop just the first.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
long li_Success
oleobject loo_Mime
long li_BAllOccurrences

li_Success = 0

loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")
if li_rc < 0 then
    destroy loo_Mime
    MessageBox("Error","Connecting to COM object failed")
    return
end if
li_Success = loo_Mime.LoadMimeFile("qa_data/message.eml")
if li_Success = 0 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Mime
    return
end if

//  Remove header fields whose name matches (case-insensitively).  The 1st argument is the field
//  name and the 2nd (bAllOccurrences) selects whether to remove all matches or only the first.
//  RemoveHeaderField is a void method.

//  Remove every X-Spam-Status header.
li_BAllOccurrences = 1
loo_Mime.RemoveHeaderField("X-Spam-Status",li_BAllOccurrences)

Write-Debug "Removed the header field(s)."


destroy loo_Mime