How can re enable pop in Gmail from C# code?(如何从 C# 代码重新启用 Gmail 中的弹出功能?)
问题描述
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:Me@gmail.com.
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 中的弹出功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 C# 代码重新启用 Gmail 中的弹出功能?


- 如何用自己压缩一个 IEnumerable 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 输入按键事件处理程序 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01