小编San*_*v S的帖子

如何使用IMAP在C#中从gmail下载附件?

我使用控制台应用程序使用IMAP服务从邮件下载文档.我在IMAP的应用程序中使用"S22.Imap"程序集.我得到的所有邮件都包含IEnumerable中的附件.我怎么能下载这些文件?

using (ImapClient client = new ImapClient(hostname, 993, username, password, AuthMethod.Login, true))
        {
            IEnumerable<uint> uids = client.Search(SearchCondition.Subject("Attachments"));
            IEnumerable<MailMessage> messages = client.GetMessages(uids,
                (Bodypart part) =>
                {
                    if (part.Disposition.Type == ContentDispositionType.Attachment)
                    {
                        if (part.Type == ContentType.Application &&
                           part.Subtype == "VND.MS-EXCEL")
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    return true;
                }
            );
       }
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

如果你给出一个解决方案,我将不胜感激

.net c# imap

3
推荐指数
1
解决办法
1万
查看次数

如何使用依赖注入继承类?

在这里,我使用DI框架(Ninject),它工作正常.但是面临的问题之一是,我有一个带有单个构造函数的基类,它接受一个接口的实现.

public class BaseApiController : ApiController
{
    readonly IAccessService _accessService; 
    public BaseApiController(IAccessService accessService)
    {
        this._accessService = accessService;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我从这个基类继承到所有其他控制器时,这些控制器具有实现自己接口的构造函数.我得到错误'BaseApiController'不包含一个带0参数的构造函数,好吧,我明白了.派生类是

 public class DiscoverController  : BaseApiController
{
    readonly IDiscoverService _discoverService;
    readonly IAccessService _accessService;

    public DiscoverController(IDiscoverService discoverService,IAccessService accessService)  
    {
        _accessService = accessService;
        _discoverService = discoverService;
    }
}
Run Code Online (Sandbox Code Playgroud)

我怎么能这样做而不修改派生类ctor采取类似的参数并将该值传递给基本ctor,如果你建议更好的方法处理这个,我将不胜感激?

c# model-view-controller dependency-injection ninject asp.net-web-api

1
推荐指数
1
解决办法
2199
查看次数

如何在没有Angular CLI的情况下在索引页面中添加bootstrap和JQuery引用

我在我的应用程序中使用VS2015和角度2.从角度快速启动解决方案创建应用程序,为了使用bootstrap css,我从nuget下载了bootstrap和jquery库.我通过内容和脚本文件夹中的拖动文件添加了这些引用.

<link href="../Content/bootstrap.css" rel="stylesheet" />
<script src="../scripts/jquery-3.2.1.min.js"></script>
<script src="../scripts/bootstrap.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

运行应用程序时,它显示错误

http:// localhost:2123/Content/bootstrap.css net :: ERR_ABORTED http:// localhost:2123/scripts/jquery-3.2.1.min.js net :: ERR_ABORTED http:// localhost:2123/scripts/bootstrap.min.js 404(未找到)

我试过以下

href="~/Content/ , href="./Content/ ,  href="Content/ Etc.
Run Code Online (Sandbox Code Playgroud)

但它仍然没有加载.如何将这些文件添加到索引页面?我是angular2的新手请给我一个解决方案.

jquery visual-studio twitter-bootstrap angular

1
推荐指数
1
解决办法
376
查看次数