POP Attachment count issue

0 votes
asked Jul 20, 2010 by Eddie (330 points)
edited Aug 10, 2010

I am able to pop message from a smtp mail server. Then I extract the attachments from each messages and save them to a location. Sometime, the Mail.Attachments.Count return 0 even there are 2 to 3 attachment there. Below is my code:

            MailMessage message = client.GetMailMessage(i);

            MessageID = message.MessageId.ToString();
            Subject = message.Subject;
            EmailFrom = message.From.ToString();
            EmailTo = message.To.ToString();
            attachmentno = message.Attachments.Count;  

There may be also something strange in outlook, when I look at that email in Outlook 2007, normally, you can save the attachments by Office Bubble -> save attachements then a dialogue pop up, but with this email, it will not come up with the dialog box, but the outlook clear shows that there are 3 attachments and you can preview them.

AM I missing something?

Thanks, Eddie

Applies to: Rebex Secure Mail

1 Answer

+1 vote
answered Jul 20, 2010 by Lukas Pokorny (124,970 points)
edited Jul 20, 2010

It's possible that the missing attachments are not in fact attachments, but rather embedded resources (a picture, for example). These are accessible through MailMessage.Resources' collection that is quite similar to theAttachments' collection. Check the value of message.Resources.Count in addition to message.Attachments.Count, it is quite possible the missing attachments will be there.

commented Jul 20, 2010 by Lukas Pokorny (124,970 points)
Pleae let us know if this doesn't solve the problem.
commented Aug 17, 2010 by Eddie (330 points)
Hi Lukas, That does the trick, thank you so much!