有誰知道的方式執行Gmail帳戶的每封電子郵件的批量轉儲和寫電子郵件到一個文件?下載電子郵件(備份)編程
我期待寫,將讓用戶備份有Gmail的(很可能是通過IMAP)的程序和備份到單個文件或爲PST(我知道PST可能會更難)
謝謝如果你能幫助
有誰知道的方式執行Gmail帳戶的每封電子郵件的批量轉儲和寫電子郵件到一個文件?下載電子郵件(備份)編程
我期待寫,將讓用戶備份有Gmail的(很可能是通過IMAP)的程序和備份到單個文件或爲PST(我知道PST可能會更難)
謝謝如果你能幫助
前一段時間我寫了一篇博客文章完全相同的話題。詳細信息請參見HOWTO: Download emails from a GMail account in C#。
代碼使用我們的Rebex Mail component:
using Rebex.Mail;
using Rebex.Net;
...
// create the POP3 client
Pop3 client = new Pop3();
try
{
// Connect securely using explicit SSL.
// Use the third argument to specify additional SSL parameters.
Console.WriteLine("Connecting to the POP3 server...");
client.Connect("pop.gmail.com", 995, null, Pop3Security.Implicit);
// login and password
client.Login(email, password);
// get the number of messages
Console.WriteLine("{0} messages found.", client.GetMessageCount());
// -----------------
// list messages
// -----------------
// list all messages
ListPop3MessagesFast(client); // unique IDs and size only
//ListPop3MessagesFullHeaders(client); // full headers
}
finally
{
// leave the server alone
client.Disconnect();
}
public static void ListPop3MessagesFast(Pop3 client)
{
Console.WriteLine("Fetching message list...");
// let's download only what we can get fast
Pop3MessageCollection messages =
client.GetMessageList(Pop3ListFields.Fast);
// display basic info about each message
Console.WriteLine("UID | Sequence number | Length");
foreach (Pop3MessageInfo messageInfo in messages)
{
// display header info
Console.WriteLine
(
"{0} | {1} | {2} ",
messageInfo.UniqueId,
messageInfo.SequenceNumber,
messageInfo.Length
);
// or download the whole message
MailMessage mailMessage = client.GetMailMessage(messageInfo.SequenceNumber);
}
}
可以使用的fetchmail從Unix環境創建MBOX文件。
http://lifehacker.com/software/gmail/geek-to-live--back-up-gmail-with-fetchmail-235207.php
有編譯到Windows(使用py2exe)一個開放源碼的Python程序在 https://github.com/jay0lee/got-your-back/wiki
但Mac用戶將需要編譯它(我的天堂由於py2exe錯誤,我完全沒有想到)。
無論哪種方式,你還需要一種方法來在計劃自動執行程序。