Go
Go
Iterate Email Headers
Demonstrates how to iterate over the email header fields.Chilkat Go Downloads
success := false
email := chilkat.NewEmail()
// First, load an email from a file.
// Note: an email object may be loaded from a file, or
// downloaded directly from a POP3 or IMAP server...
success = email.LoadEml("testReceivedHdrs.eml")
if success != true {
fmt.Println(email.LastErrorText())
email.DisposeEmail()
return
}
// How many header fields?
var n int
n = email.NumHeaderFields()
if n > 0 {
// Display the name and value of each header:
var i int
var name *string = new(string)
var value *string = new(string)
for i = 0; i <= n - 1; i++ {
name = email.GetHeaderFieldName(i)
value = email.GetHeaderFieldValue(i)
fmt.Println(i)
fmt.Println(*name)
fmt.Println(*value)
}
}
email.DisposeEmail()