This project is read-only.

Attachment Connect

Jun 15, 2009 at 9:10 PM

Hi,

I can able to get the attachment in tha body part, but I can't able to read the content of the attachement. i.e.  Data property of the bodypart is null.


                ImapConnect connection = new ImapConnect("HostServer", 143);

                ImapCommand command = new ImapCommand(connection);
                ImapAuthenticate auth = new ImapAuthenticate(connection, "UserID", "Password");
                bool isConnected = connection.Open();
                auth.Login();
                ImapMailbox mailbox = command.Select("folderName");
                mailbox = command.Fetch(mailbox);

                int i = mailbox.Messages.Count;
               

                if (mailbox != null && mailbox.Messages != null)
                {

                    foreach (ImapMailboxMessage message in mailbox.Messages)
                    {
                        ImapMailboxMessage msg;
                        msg = command.FetchBodyStructure(message);

                        foreach (ImapMessageBodyPart bodyPart in msg.BodyParts)
                        {
                            string from = msg.From.DisplayName;
                            if (bodyPart.Attachment)
                            {
                                if (bodyPart.ContentType.MediaType.Equals("APPLICATION/OCTET-STREAM"))
                                {
                                    //MessageBox.Show(bodyPart.BodyPart);
                                    bodyPart.ContentEncoding = BodyPartEncoding.NONE;
                                    string content = bodyPart.Data;  I am not able to get the content of the attachment here.
                                }
                               
                            }
                           

                        }
                     }

Could anyone pls help me.