IMAP 获取响应问题

发布于 2024-10-18 06:17:40 字数 854 浏览 2 评论 0原文

我正在使用 IMAP,阅读邮件内容时我收到了两次或三次相同的邮件内容。

我检查了不同的不同场景,所以我知道 Response() 给了我重复性 内容。

我像这样传递命令。

                byte[] commandBytes = System.Text.Encoding.ASCII.GetBytes(("$ UID FETCH " + index + " (BODY[HEADER.FIELDS (SUBJECT FROM DATE)])" + "\r\n").ToCharArray());
        _imapNs.Write(commandBytes, 0, commandBytes.Length);
        _imapNs.Flush();
        string strMsg = Response();

我的 Stream 和 TcpClient 成员是。

private TcpClient _imapClient;
private Stream _imapNs;

我的响应方法在这里。

private string Response()
{
    byte[] data = new byte[_imapClient.ReceiveBufferSize];
    int ret = _imapNs.Read(data, 0, data.Length);
    return Encoding.ASCII.GetString(data);
}

一旦我检查了这个完整的周期,我就知道 Response() 方法给了我重复的内容,所以有没有解决方案......

谢谢......!!

Iam working on IMAP, reading mail content I got twice or third times of same mails content.

I had check out different different scenario so I comes to know Response() was gives me repeatitive
content.

I am passing Command like this.

                byte[] commandBytes = System.Text.Encoding.ASCII.GetBytes(("$ UID FETCH " + index + " (BODY[HEADER.FIELDS (SUBJECT FROM DATE)])" + "\r\n").ToCharArray());
        _imapNs.Write(commandBytes, 0, commandBytes.Length);
        _imapNs.Flush();
        string strMsg = Response();

my member of Stream and TcpClient is.

private TcpClient _imapClient;
private Stream _imapNs;

and my Response method is here.

private string Response()
{
    byte[] data = new byte[_imapClient.ReceiveBufferSize];
    int ret = _imapNs.Read(data, 0, data.Length);
    return Encoding.ASCII.GetString(data);
}

once I had check this complete cycle then I comes to knows the Response() method gives me repeatitive content so is there any solution for that.....

Thanks...!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

〆凄凉。 2024-10-25 06:17:40

你的代码不可能工作。

您假设服务器响应小于 _imapClient.ReceiveBufferSize。为什么?

服务器响应可能有 50 MB 长。您无法通过对 Stream.Read 方法的单次调用来读取它。

There is no way your code will work.

You have assumed that the server response is smaller than _imapClient.ReceiveBufferSize. Why?

Server response may be 50 MB long. There is no way you'll be able to read it with the single call to Stream.Read method.

十年不长 2024-10-25 06:17:40

我建议您使用可用于 C# 的众多库之一(由于示例的语法,我假设您正在使用该库 - 您没有指定)。

查看现有的 StackOverflow 问题。

在 C# 中访问 IMAP

使用 C# .NET 库检查来自 GMail 服务器的 IMAP 邮件

I would recommend that you use one of the many libraries available for C# (I'm assuming that's what you're using due to the syntax of your example - you didn't specify).

Take a look at the existing StackOverflow questions.

Accessing IMAP in C#

Using C# .NET librarires to check for IMAP messages from GMail servers

忆梦 2024-10-25 06:17:40

我得到了解决方案,因为我想做循环内的所有事情,并且我正在循环外做所有的事情谢谢..!!

I got the Solution, because I want to do all the thing inside the loop and I am doing all the thins outside the loop Thanks..!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文