【问题标题】:C# WPF Gmail Sign and Count EmailsC# WPF Gmail 签名和计数电子邮件
【发布时间】:2015-03-02 18:27:41
【问题描述】:

您好,我需要通过 gmail 的 pop3 计数消息。我有这个代码。

public int MessageCount
        {
            get
            {
                sWriter.WriteLine("stat");
                sWriter.Flush();
                string[] splitResponse = GetResponse().Split(' ');
                return Convert.ToInt32(splitResponse[1]);
            }
        }

错误:在 ImapDemo.exe 中出现“System.IndexOutOfRangeException”类型的第一次机会异常 你能帮忙吗?

【问题讨论】:

    标签: c# wpf email smtp gmail


    【解决方案1】:

    您的数组不包含您要搜索的索引。您可以在尝试使用它之前简单地检查它是否存在。不过,我不确定您为什么要查看数组中的第二项来获取电子邮件计数。

                if(splitResponse.length > 1) return Convert.ToInt32(splitResponse[1]);
                else return -1;//or indicate a failure some other way
    

    【讨论】:

      猜你喜欢
      • 2021-09-24
      • 1970-01-01
      • 2021-12-24
      • 2022-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-24
      • 2021-09-21
      相关资源
      最近更新 更多