I am trying to parse my emails in Go and I need help.
How to get access to Content-type field of mail?
cmd, _ = c.Fetch(set, "BODY[HEADER]", "BODY[1]")
for cmd.InProgress() {
for _, rsp = range cmd.Data {
header := imap.AsBytes(rsp.MessageInfo().Attrs["BODY[HEADER]"])
body := imap.AsString(rsp.MessageInfo().Attrs["BODY[1]"])
if msg, _ := mail.ReadMessage(bytes.NewReader(header)); msg != nil {
with this I can gain access to Body and Header, but when email contain included file then with BODY[1]
I have all meta-data, not only pure text. To avoid that I can use BODY[1.1]
, but I need condition by Content-Type:[multipart/alternative]
and I can't gain access ot that field.