This project is read-only.

Attachement from mail

Jun 15, 2009 at 8:02 PM


I have started to use you KoolWired IMap. Could you please let me know the way to get the attachments from a mails. 

Your help will be much appreciable. 

Thanks in Advance.

Nov 17, 2009 at 11:03 PM

I am also trying to figure out this functionlity.  Any examples would be very much welcome.  Thanks in advance...

Nov 18, 2009 at 1:46 AM

Hope this helps:


        ImapMailboxMessage mbStructure = new ImapMailboxMessage();
        mbStructure.ID = _message.ID;
        mbStructure = command.FetchBodyStructure(mbStructure);

          for (int i = 0; i < mbStructure.BodyParts.Count; i++)
            if (mbStructure.BodyParts[i].Attachment)
              mbStructure = command.FetchBodyPart(mbStructure, i, _affectSeen);

              MailAttachment attachment = new MailAttachment();
              attachment.ContentId = mbStructure.BodyParts[i].ContentID;
              attachment.Data = mbStructure.BodyParts[i].DataBinary;
              attachment.Encoding = mbStructure.BodyParts[i].Encoding;
              attachment.MimeType = mbStructure.BodyParts[i].ContentType;
              attachment.Size = mbStructure.BodyParts[i].Size;
              attachment.Name = mbStructure.BodyParts[i].FileName;
              attachment.Filename = mbStructure.BodyParts[i].FileName;
              attachment.IsInline = mbStructure.BodyParts[i].Inline;

Nov 18, 2009 at 3:15 PM

Perfect, thank you.  I assume MailAttachment is a type you defined because i don't see it in the exisitng structure...

That gave me everything i need though.  Thanks again.