【发布时间】:2018-03-16 13:29:22
【问题描述】:
您好,我使用 Openpop.net 阅读了我的 gmail,例如 Here。
由此我可以获取邮件数据(发件人、日期、主题、正文)并将其存储到 sql server 中。但我需要知道如何将附件保存到 sql server 中。
这里我们获取附件如下,
List<MessagePart> attachments = message.FindAllAttachments();
foreach (MessagePart attachment in attachments)
{
email.Attachments.Add(new Attachment
{
FileName = attachment.FileName,
ContentType = attachment.ContentType.MediaType,
Content = attachment.Body
});
}
在SQL SERVER中我的附件表如下
CREATE TABLE [dbo].[Email_Attachment](
[Id] [int] IDENTITY(1,1) NOT NULL,
[MessagId] [varchar](500) NULL,
[AttachmentFileName] [varchar](500) NULL,
[AttachmentContentType] [varchar](500) NULL,
[AttachmentContent] [varbinary](max) NULL)
如何将附件保存到 sql 表中。附件是pdf、jpg、ppt等... 我需要了解如何保存和检索附件。
【问题讨论】: