如何重新启用从C#代码在Gmail中流行

如何重新启用从C#代码在Gmail中流行

本文介绍了如何重新启用从C#代码在Gmail中流行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的Gmail下载邮件,我选择的单选按钮的程序:针对所有邮件启用POP(就算该邮件已经下载)



在我下载我的邮件我的Gmail改变以上状况: POP为自当前日期



已收到的所有邮件启用

我没有物理变化的单选按钮,但它接缝像它自动将其设置为只下载新邮件。



我需要我的窗户向下负载我所有的一切的时候。



我怎么能在我的代码集这Gmail的必须启用所有下载所有的时间?与出我不必去重新选择每一次的单选按钮。






Windows服务

 命名空间EmailWindowsService 
{
公共部分类MyEmailService:ServiceBase
{
私有静态System.Timers.Timer aTimer ; //创建一个定时器
公共MyEmailService()
{
的InitializeComponent();
如果(!System.Diagnostics.EventLog.SourceExists(MYSOURCE))//记录每一个事件
{
System.Diagnostics.EventLog.CreateEventSource(
MYSOURCE MyNewLog); //创建事件源可以在服务器资源管理器
}
eventLogEmail.Source =MYSOURCE查看;
eventLogEmail.Log =MyNewLog;
//定时器代码
aTimer =新System.Timers.Timer(1 * 60 * 1000); //60秒
aTimer.Elapsed + =新ElapsedEventHandler(OnTimedEvent); //调用时间已过事件
aTimer.Enabled = TRUE;
//定时器代码
}
保护覆盖无效的OnStart(字串[] args)
{
eventLogEmail.WriteEntry(已启动);
}
保护覆盖无效调用OnStop()
{
eventLogEmail.WriteEntry(停止);
}
保护覆盖无效的onPause()
{
eventLogEmail.WriteEntry(暂停);
}
保护覆盖无效OnContinue()
{
eventLogEmail.WriteEntry(继续);
}
保护覆盖无效OnShutdown()
{
eventLogEmail.WriteEntry(ShutDowned);
}
私人无效OnTimedEvent(对象源,ElapsedEventArgs E)
{
clsRetriveEmail电子邮件=新clsRetriveEmail();
eventLogEmail.WriteEntry(Populateing与邮件数据库); //记录事件
Emails.EmailGetList(); //调用类
}
}
}






 命名空间EmailWindowsService 
{
类clsRetriveEmail
{
使用公共无效EmailGetList()
{
(Pop3Client objClient =新Pop3Client())
{
//及认证这被存储在在app.config文件
objClient.Connect(Properties.Settings.Default.mailServer,Properties.Settings.Default.port,Properties.Settings.Default.ssl​​); //邮件服务器如Gmail是pop.gmail.com,端口公共端口995 110 SLL安全性最好设置为true
objClient.Authenticate(Properties.Settings.Default.username,Properties.Settings.Default.password); //电子邮件地址和密码
//计数的电子邮件,并开始循环,虽然它们
INT emailCount = objClient.GetMessageCount();
的for(int i = emailCount; I> = 1;我 - )
{
OpenPop.Mime.Message味精= objClient.GetMessage(I) //获取信息的数量。消息decleard味精
//设置值扔进数据库
INT EMAILID = I;
字符串emailTo = Properties.Settings.Default.username;
字符串emailFrom = msg.Headers.From.Address;
字符串Emailsubject的= msg.Headers.Subject;
的DateTime emailSentDate = msg.Headers.DateSent;
//连接字符串可以在app.config文件
//连接时使用(VAR康恩=新的SqlConnection(Properties.Settings.Default.dbConnectionString))$ B改为数据库
使用$ b(VAR CMD = conn.CreateCommand())
{
//写入数据库(本地)实例
conn.Open();
cmd.CommandText =EmailLogFill;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(@ ID,EMAILID);
cmd.Parameters.AddWithValue(@为,emailTo);
cmd.Parameters.AddWithValue(@从emailFrom);
cmd.Parameters.AddWithValue(@主题,Emailsubject的);
cmd.Parameters.AddWithValue(@日,emailSentDate);
cmd.ExecuteNonQuery();
}
}
}
}
}
}


解决方案

您不需要重新启用无线电按钮,当弹出客户端下载邮件,它不能是鉴于其他流行的客户端。后市如何做到这一点是使用最近模式。



试试这个它不是所有的邮件,但在过去30天。



只是添加的近期以您的用户名如近期:[email protected]



最近模式获取邮件的最后30天,无论其是否已被发送到另一个POP1客户端了。



链接回它。




I have a program that downloads mails from my Gmail, i have selected the radio button : Enable POP for all mail (even mail that's already been downloaded)

After i download my mail my Gmail changes the status above to: POP is enabled for all mail that has arrived since current Date

I did not physical change the radio buttons but it seams like it auto sets it to download only new mail.

I need my windows to down load all my all the time.

How can i set in my code that Gmails must enable all downloads all the time? with out me having to go re select the radio button every time.


Windows Service

 namespace EmailWindowsService
{
    public partial class MyEmailService : ServiceBase
    {
        private static System.Timers.Timer aTimer; //Create a timer
        public MyEmailService()
        {
            InitializeComponent();
            if (!System.Diagnostics.EventLog.SourceExists("MySource")) // Log every event
            {
                System.Diagnostics.EventLog.CreateEventSource(
                    "MySource", "MyNewLog"); // Create event source can view in Server explorer
            }
            eventLogEmail.Source = "MySource";
            eventLogEmail.Log = "MyNewLog";
            // Timer Code
             aTimer = new System.Timers.Timer(1 * 60 * 1000); // 60 seconds
             aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); // Call time elapsed event
             aTimer.Enabled = true;
            // Timer Code
        }
        protected override void OnStart(string[] args)
        {
            eventLogEmail.WriteEntry("Started");
        }
        protected override void OnStop()
        {
            eventLogEmail.WriteEntry("Stopped");
        }
        protected override void OnPause()
        {
            eventLogEmail.WriteEntry("Paused");
        }
        protected override void OnContinue()
        {
            eventLogEmail.WriteEntry("Continuing");
        }
        protected override void OnShutdown()
        {
            eventLogEmail.WriteEntry("ShutDowned");
        }
        private void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            clsRetriveEmail Emails = new clsRetriveEmail();
            eventLogEmail.WriteEntry("Populateing database with mail"); // log event
            Emails.EmailGetList(); // Call class
        }
        }
    }


Class

namespace EmailWindowsService
{
    class clsRetriveEmail
    {
        public void EmailGetList()
        {
            using (Pop3Client objClient = new Pop3Client())
            {
                //Athentication This is stored in the app.config file
                objClient.Connect(Properties.Settings.Default.mailServer, Properties.Settings.Default.port, Properties.Settings.Default.ssl); // mailserver eg gmail is pop.gmail.com, Port common ports 995 110 sll Security best to set to true
                objClient.Authenticate(Properties.Settings.Default.username, Properties.Settings.Default.password);  // Email Address and password
                //Count Emails and begin Looping though them
                int emailCount = objClient.GetMessageCount();
                for (int i = emailCount; i >= 1; i--)
                {
                   OpenPop.Mime.Message msg = objClient.GetMessage(i); //Get message Number. Message decleard as msg
                    //Set the values to throw into Database
                   int emailID = i;
                   String emailTo = Properties.Settings.Default.username;
                   String emailFrom = msg.Headers.From.Address;
                   String emailSubject = msg.Headers.Subject;
                   DateTime emailSentDate = msg.Headers.DateSent;
                    // The connection String can be changed in the app.config file
                    // Connect to database
                    using (var conn = new SqlConnection(Properties.Settings.Default.dbConnectionString))
                    using (var cmd = conn.CreateCommand())
                    {
                            // Writes to database (local) instance
                            conn.Open();
                            cmd.CommandText = "EmailLogFill";
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.AddWithValue("@id", emailID);
                            cmd.Parameters.AddWithValue("@to", emailTo);
                            cmd.Parameters.AddWithValue("@from", emailFrom);
                            cmd.Parameters.AddWithValue("@subject", emailSubject);
                            cmd.Parameters.AddWithValue("@date", emailSentDate);
                            cmd.ExecuteNonQuery();
                    }
                }
            }
        }
    }
}
解决方案

You don't need to re enable the radio button, when a pop client downloads the mail, it cant be view by other pop clients. How outlook does this is by using the recent mode.

Try this its not all your mail but the last 30 days.

Just Add recent: to your username e.g recent:[email protected].

Recent mode fetches the last 30 days of mail, regardless of whether it's been sent to another POP1 client already.

Link to back it up.

http://support.google.com/mail/bin/answer.py?hl=en&answer=47948

这篇关于如何重新启用从C#代码在Gmail中流行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 19:33