Downloading and restoring attachments in

I've been using to retrieve emails from a server. For the time being I skipped the functionality of downloading attachment emails to keep things simple. Now I need to go back and enable this functionality. A couple questions.
#1 Does automatically download the attachments as part of the message? Will I need to download the messages separately? I currently use:
foreach (OpenPop.Mime.Message m in newMessages)
#2 If I load the message how do I add all the existing attachments of saved email to the new email to be sent out (restored) to the server?
I've got something like this so far:
                        List<MessagePart> attachments = message.FindAllAttachments();
                        foreach (MessagePart attachment in attachments)
                            SendMessage.Attachments.Add(new Attachment
                                FileName = attachment.FileName,
                                ContentType = attachment.ContentType.MediaType,
                                Content = attachment.Body
But the problem with this is that FileName and Content both have those little red squiggly lines underneath them. I can change FileName to "Name" but I can't figure out what Content would be. Any help would be appreciated.
Who is Participating?
drayneConnect With a Mentor Author Commented:
Here was the answer:
                        //Get the attachments
                        IEnumerable<MessagePart> attachments = message.FindAllAttachments();
                        foreach (MessagePart attachmentMessagePart in attachments)
                            MemoryStream stream = new MemoryStream(attachmentMessagePart.Body);
                            Attachment attachment = new Attachment(stream, attachmentMessagePart.ContentType);
                            attachment.Name = attachmentMessagePart.FileName;
                            attachment.ContentId = attachmentMessagePart.ContentId;
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.