0

Gmail からメールをダウンロードするプログラムを持っています。ラジオ ボタンを選択しました:すべてのメールに対して POP を有効にする (ダウンロード済みのメールも含む)

メールをダウンロードした後、Gmail のステータスが次のように変わります:現在の日付以降に到着したすべてのメールに対して POP が有効になっています

ラジオボタンを物理的に変更しませんでしたが、新しいメールのみをダウンロードするように自動設定されているようです。

常にウィンドウをダウンロードする必要があります。

Gmail で常にすべてのダウンロードを有効にする必要があることをコードで設定するにはどうすればよいですか? 毎回ラジオボタンを選択し直す必要はありません。


Windows サービス

 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
        }       
        }
    }

クラス

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();
                    }
                }
            }
        }
    }
}
4

1 に答える 1

0

ラジオ ボタンを再度有効にする必要はありません。ポップ クライアントがメールをダウンロードすると、他のポップ クライアントからは表示されなくなります。Outlook がこれを行う方法は、最近のモードを使用することです。

すべてのメールではなく、過去 30 日間を試してみてください。

recent:Me@gmail.com のようにユーザー名にrecent:を追加するだけです。

最近のモードでは、別の POP1 クライアントに既に送信されているかどうかに関係なく、過去 30 日間のメールが取得されます。

リンクしてバックアップします。

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

于 2012-05-11T06:03:10.197 に答える