Visual Basic 6.0
Visual Basic 6.0
Prepend Added Header Fields to the Top
See more Email Object Examples
Demonstrates the Chilkat Email.PrependHeaders property. When true, header fields added through AddHeaderField or AddHeaderField2 are placed at the top of the header rather than appended at the bottom (the default is false). This affects only fields added after the property is set — it does not reorder fields that are already present. This example enables prepending and adds two custom header fields.
Background: In a MIME message the order of header fields is mostly cosmetic, but there are cases where "top vs bottom" matters — for instance, trace headers like
Received are conventionally added to the top so the most recent hop appears first, and some pipelines expect certain fields early in the header block. PrependHeaders gives you control over placement when you add your own custom fields.Chilkat Visual Basic 6.0 Downloads
' Demonstrates the Email.PrependHeaders property. When true, header fields added via
' AddHeaderField (or AddHeaderField2) are prepended to the top of the header instead of
' appended to the bottom. The default is false.
Dim email As New ChilkatEmail
email.Subject = "Prepend headers demo"
email.From = "mary@example.com"
' Cause subsequently-added header fields to go to the top of the header.
email.PrependHeaders = 1
email.AddHeaderField "X-Custom-One","first value"
email.AddHeaderField "X-Custom-Two","second value"
Debug.Print email.Header