Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用cmail.dll时出错_C#_Email_Gmail - Fatal编程技术网

C# 使用cmail.dll时出错

C# 使用cmail.dll时出错,c#,email,gmail,C#,Email,Gmail,我正试图通过一个gmail帐户读取gps数据,这些数据是通过手机发送到那里的 using (Pop3Client cl = new Pop3Client()) { cl.UserName = "crash893"; cl.Password = "password"; cl.ServerName = "pop.gmail.com"; cl.Auth

我正试图通过一个gmail帐户读取gps数据,这些数据是通过手机发送到那里的

using (Pop3Client cl = new Pop3Client())
            {
                cl.UserName = "crash893";
                cl.Password = "password";
                cl.ServerName = "pop.gmail.com";
                cl.AuthenticateMode = Pop3AuthenticateMode.Pop;
                cl.Ssl = true;
                cl.Authenticate();
                ///Get first mail of my mailbox
                Pop3Message mg = cl.GetMessage(1);  <<<<<<<<<< ERROR
                String MyText = mg.BodyText;
                ///If the message have one attachment
                Pop3Content ct = mg.Contents[0];
                ///you can save it to local disk
                ct.DecodeData("c:\\test.txt");
            }
理想情况下,我想做的是打开此帐户,阅读此帐户中某一主题行的所有新未读电子邮件,然后阅读正文中的数据,并将其标记为已读

有人知道为什么会出错吗


是否有人对cmail有任何经验,他们可以为我指出正确的阅读方向,并将电子邮件标记为read等

不可能使用POP协议将电子邮件标记为read


尝试使用IMAP。

使用POP协议无法将电子邮件标记为已读


尝试使用IMAP。

我没有使用CMail的经验,这个答案可能没有帮助,但我过去在尝试编写电子邮件发送/接收相关代码时遇到过奇怪的情况


结果表明,我们在工作中运行的防病毒软件有一个允许的.EXE的白名单,可以进行入站/出站POP3或SMTP连接。这有可能是你的问题吗?

我没有使用CMail的经验,这个答案可能没有帮助,但我过去在尝试编写电子邮件发送/接收相关代码时遇到过奇怪的情况


结果表明,我们在工作中运行的防病毒软件有一个允许的.EXE的白名单,可以进行入站/出站POP3或SMTP连接。这有可能是你的问题吗?

cl.Port=995

cl.Port=995

你确定吗?outlook是如何通过pop3实现的?您是否有易于使用的免费imap客户端?outlook不是通过pop3实现的。在Outlook中将邮件标记为已读时,它会更新本地数据库。Outlook和POP服务器之间的唯一交互是首先下载邮件。要使用IMAP执行此操作,您还需要在手机上重新配置Outlook以使用IMAP连接到Gmail。您可以在此处找到.Net IMAP客户端:。或者,尝试搜索堆栈溢出或Googleare,确定吗?outlook是如何通过pop3实现的?您是否有易于使用的免费imap客户端?outlook不是通过pop3实现的。在Outlook中将邮件标记为已读时,它会更新本地数据库。Outlook和POP服务器之间的唯一交互是首先下载邮件。要使用IMAP执行此操作,您还需要在手机上重新配置Outlook以使用IMAP连接到Gmail。您可以在此处找到.Net IMAP客户端:。或者,尝试搜索堆栈溢出或GoogleTotal。您可能应该将total设置为long not int,并删除Convert.ToInt16。您可能应该将total设置为long not int,并删除Convert.ToInt16。
        using (Pop3Client cl = new Pop3Client())
        {
            cl.UserName = "ewgsdssw";
            cl.Password = "sdgwsegw";
            cl.ServerName = "pop.gmail.com";
            cl.AuthenticateMode = Pop3AuthenticateMode.Pop;
            cl.Port = 995;
            cl.Ssl = true;
            cl.Authenticate();
            ///Get first mail of my mailbox
            ///
            int total = Convert.ToInt16(cl.GetTotalMessageCount());

            while (total >= 1)
            {
                Pop3Message mg = cl.GetMessage(total);
                if (mg.Subject == "I am Here")
                {

                    // http://maps.google.com/maps?q=38.89552,-77.43265
                    //(+/- 76 metres.)

                    string location = mg.BodyText;
                    location = location.Replace("http://maps.google.com/maps?q=","~");
                    location = location.Replace("metres.)\r\n\r\n","~");

                    location = location.Split('~')[1];

                    location = location.Replace("(+/- ", ",");
                    location = location.Replace("\r\n", "");


                    string[] data = location.Split(',');
                    string lat = data[0];
                    string lon = data[1];
                    string res = data[2];
                    DateTime time = mg.Date;

                    textBox1.AppendText(string.Format("Lat: {0} LON: {1} Res: {2} TIME: {3}\r\n",lat,lon,res,time.ToString()));

                }

                total--;
            }

        }
        using (Pop3Client cl = new Pop3Client())
        {
            cl.UserName = "ewgsdssw";
            cl.Password = "sdgwsegw";
            cl.ServerName = "pop.gmail.com";
            cl.AuthenticateMode = Pop3AuthenticateMode.Pop;
            cl.Port = 995;
            cl.Ssl = true;
            cl.Authenticate();
            ///Get first mail of my mailbox
            ///
            int total = Convert.ToInt16(cl.GetTotalMessageCount());

            while (total >= 1)
            {
                Pop3Message mg = cl.GetMessage(total);
                if (mg.Subject == "I am Here")
                {

                    // http://maps.google.com/maps?q=38.89552,-77.43265
                    //(+/- 76 metres.)

                    string location = mg.BodyText;
                    location = location.Replace("http://maps.google.com/maps?q=","~");
                    location = location.Replace("metres.)\r\n\r\n","~");

                    location = location.Split('~')[1];

                    location = location.Replace("(+/- ", ",");
                    location = location.Replace("\r\n", "");


                    string[] data = location.Split(',');
                    string lat = data[0];
                    string lon = data[1];
                    string res = data[2];
                    DateTime time = mg.Date;

                    textBox1.AppendText(string.Format("Lat: {0} LON: {1} Res: {2} TIME: {3}\r\n",lat,lon,res,time.ToString()));

                }

                total--;
            }

        }