小编ski*_*per的帖子

当SMTP服务器收到新电子邮件时,通知C#客户端

我想在我的ASP.NET应用程序中获取具有特定CC收件人的所有电子邮件.要将此用于将来的电子邮件,我不想一直轮询来获取它们.但我找不到办法,如何使用push立即收到电子邮件.他们在C#中的任何框架都可以帮助我吗?

我想将我的应用程序连接到邮件服务器并注册方法"X".总是当新邮件到达邮件服务器时,我的应用程序必须得到通知,我的应用程序应该执行方法'X'.

我希望这可以用这样的代码:

void Application_Start() 
{
    ...
    ConnectWithTheSmtpServer();
    RegisterMethodForNotification(DoSomethink);
    ...
}
void DoSomethink(Mail newMail)
{
    // Do Somethink with the mail
}
Run Code Online (Sandbox Code Playgroud)

编辑:

我用MailSystem.Net做到了.它工作得很好,很容易实现.

示例代码:

void Application_Start() 
{
    var worker = new BackgroundWorker();
    worker.DoWork += new DoWorkEventHandler(StartIdleProcess);

    if (worker.IsBusy)
        worker.CancelAsync();

    worker.RunWorkerAsync();
}

private void StartIdleProcess(object sender, DoWorkEventArgs e)
{
    if (_imap != null && _imap.IsConnected)
    {
        _imap.StopIdle();
        _imap.Disconnect();
    }

        _imap = new Imap4Client();
        _imap.ConnectSsl(server-name, 993);
        _imap.Login(username, passwort);

        var inbox = _imap.SelectMailbox("INBOX");

        _imap.NewMessageReceived += new NewMessageReceivedEventHandler(NewMessageReceived);

        inbox.Subscribe();

        _imap.StartIdle();
    } …
Run Code Online (Sandbox Code Playgroud)

.net c# email push

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

如何在C#中从模板创建*.docx文件

我有一个有效的ASP.NET MVC Web应用程序来管理项目和客户.现在我想为一些客户生成一个word文件.在此文件中应显示有关客户的一些数据.每个生成的文件都应具有相同的数据和相同的设计.所以我想用字段来创建一个新的Word模板,并希望以编程方式填充占位符.

我的问题是我找不到明确的方法来做到这一点.有人知道一个好的学习资源吗?

.net c# ms-word docx openxml

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

离开网站后,在localStorage中保存jqGrid的状态

我想保存jqGrid(排序列,排序顺序,列宽,工具栏搜索字段)的状态,当用户离开站点并在他返回站点时恢复网格.

我的第一次尝试是使用该getGridParam方法加载数据,然后使用JSON对其进行序列化,并将其作为JSON-String保存在cookie中.但是cookie没有足够的空间来保存gridParam.所以我决定使用localstorage来保存Grid的状态.我的代码看起来像这样:

$(window).unload(function () {
    // Load GridParam
    var gridData = $('#Grid').jqGrid('getGridParam')};
    // Serialize it to as JSON-String
    var gridDataAsString = $.toJSON(gridData);
    // Save the serialized Griddata in the localStorage
    localStorage.setItem("GridParam", gridDataAsString);
});
Run Code Online (Sandbox Code Playgroud)

这很好用.但是在下一步中我从localStroage加载GridParam并尝试恢复网格.加载数据也没问题.在调试模式下,我可以看到所有数据都是从localStorage正确加载的.但是,如果我想使用该setGridParam方法恢复网格,则网格具有所有默认值.我的代码如下所示:

$(document).ready(function () {
    $("#Grid").jqGrid({ /* Initialize the grid with default values */ });

    var loadedGridDataAsString = localStorage.getItem("GridParam");
    // Use the default value if no data exists in localStorage
    if (loadedGridDataAsString != null) {
        // Deserialize the JSON-String to an object
        var loadedGridData …
Run Code Online (Sandbox Code Playgroud)

jqgrid local-storage

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

标签 统计

.net ×2

c# ×2

docx ×1

email ×1

jqgrid ×1

local-storage ×1

ms-word ×1

openxml ×1

push ×1