コード例 #1
0
        private void SaveAttachments(Message pop3mail, MailMessage message)
        {
            string mailTempFolder = Path.Combine(tempFolder, pop3mail.Headers.MessageId);

            Directory.CreateDirectory(mailTempFolder);
            foreach (var pop3attachment in pop3mail.FindAllAttachments())
            {
                string tempFile = Path.Combine(mailTempFolder, pop3attachment.FileName);
                logger.SavingIncomingMailAttachmentTo(tempFile);
                var fi = new FileInfo(tempFile);
                pop3attachment.Save(fi);
                logger.SavedIncomingMailAttachmentTo(tempFile);
                var attachment = new MailAttachment()
                {
                    Name          = pop3attachment.FileName,
                    LocalDumpFile = tempFile
                };
                message.Attachments.Add(attachment);
            }//for
        }