简体   繁体   English

ImapX没有给我发送电子邮件主题/消息信息:

[英]ImapX not giving me the email subject/message info:

The line of listBox1.Items.Add(from + ": " + x.Subject); listBox1.Items.Add(from +“:” + x.Subject); Is what is not returning a desired result, it adds ": " instead of "FirstNameLastName: Subject title" 是什么没有返回期望的结果,而是添加了“:”而不是“ FirstNameLastName:主题标题”

https://imapx.codeplex.com/wikipage?title=Sample%20code%20for%20get%20messages%20from%20your%20inbox https://imapx.codeplex.com/wikipage?title=示例%20code%20for%20get%20messages%20from%20your%20inbox

and https://imapx.codeplex.com/ https://imapx.codeplex.com/

    List<Task> m = new List<Task>();
    private async void cmdLogin_Click(object sender, EventArgs e)
    {
        bool result = imapMail.Connection();
        if (result)
        {
            result = imapMail.LogIn(email, password);
            if (result)
            {
                var messes = imapMail.Folders[inbox].Messages;
                foreach (var x in messes)
                {
                    string from = "";
                    foreach (var addresses in x.From)
                    {
                        from = addresses.DisplayName;
                    }
                    listBox1.Items.Add(from + ": " + x.Subject);
                }
                foreach (ImapX.Message msgs in imapMail.Folders[inbox].Messages)
                {
                    m.Add(new Task(new Action(() => msgs.Process())));
                }
                await Task.WhenAll(m);

            }
            else { this.Text = "failed login"; }
        }
        else { this.Text = "Failed connection"; }
    }
}

this isn't returning anything besides a colon, it should be returning a Display Name: Message Subject 除了冒号外,它不返回任何内容,应该返回显示名称:Message Subject

Before you can retrieve the message details (like "from", "subject", etc.), you first need to call Process() on the message. 在检索消息详细信息(如“来自”,“主题”等)之前,您首先需要在消息上调用Process()。 If you look at the source code for ImapX , you'll see that Process() involves a server call to the IMAP server, to download the message data. 如果查看ImapX源代码 ,则会看到Process()涉及对IMAP服务器的服务器调用,以下载消息数据。

It looks like you are trying retrieving the From address BEFORE you are calling Process(), and that will return an empty string. 看来您在调用Process()之前正在尝试检索“发件人”地址,这将返回一个空字符串。 You need to change the order - call Process() first, and only afterwards can you check the message details. 您需要更改顺序-首先调用Process(),然后才能检查消息详细信息。

See the code below. 请参见下面的代码。 I haven't tested this yet. 我还没有测试过。

List<Task> m = new List<Task>();
private async void cmdLogin_Click(object sender, EventArgs e)
{
    bool result = imapMail.Connection();
    if (result)
    {
        result = imapMail.LogIn(email, password);
        if (result)
        {
            foreach (ImapX.Message msgs in imapMail.Folders[inbox].Messages)
            {
                m.Add(new Task(new Action(() => msgs.Process())));
            }
            await Task.WhenAll(m);

            var messes = imapMail.Folders[inbox].Messages;
            foreach (var x in messes)
            {
                string from = "";
                foreach (var addresses in x.From)
                {
                    from = addresses.DisplayName;
                }
                listBox1.Items.Add(from + ": " + x.Subject);
            }
        }
        else { this.Text = "failed login"; }
    }
    else { this.Text = "Failed connection"; }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM