相关疑难解决方法(0)

使用MailKit库保存附件?

我正在尝试学习如何使用MailKit库,但我正在努力检索附件.到目前为止,我的代码将打开一个邮箱,浏览每个邮件并存储数据,如发件人,主题,正文,日期等,但我不能处理附件.

我试图在github和其他网站上使用其他人解决方案,但我仍然不明白他们在代码中做了什么,当我接近获得解决方案时,它会导致更多错误,所以我会感到压力并删除所有代码.我并不是说看起来很懒,但如果有人能解释我是如何做到的,我会很高兴.我基本上是在为Web表单应用程序构建一个邮件客户端.

下面是我的代码,所以你可以看到我相当无能:)

        // Open the Inbox folder
        client.Inbox.Open(FolderAccess.ReadOnly, cancel.Token);

        //get the full summary information to retrieve all details
        var summary = client.Inbox.Fetch(0, -1, MessageSummaryItems.Full, cancel.Token);
        foreach (var msg in summary)
        {
            //this code originally downloaded just the text from the body
            var text = msg.Body as BodyPartText;
            //but I tried altering it so that it will get attachments here also
            var attachments = msg.Body as BodyPartBasic;

            if (text == null)
            {
                var multipart = msg.Body as BodyPartMultipart;

                if (multipart …
Run Code Online (Sandbox Code Playgroud)

c# asp.net imap mailkit

7
推荐指数
2
解决办法
8079
查看次数

标签 统计

asp.net ×1

c# ×1

imap ×1

mailkit ×1