2009-05-29 16 views
6

)Gmailアカウントのすべての電子メールの一括ダンプを実行して電子メールをファイルに書き込む方法を知っている人はいますか?私は(おそらくIMAP経由)バックアップがユーザーのGmailを聞かせプログラムを書いて、個々のファイルのいずれかまたはpstファイルとしてそれをバックアップしているよgmailからプログラムで電子メールをダウンロードする(

(私はPSTは、おそらくはるかに困難になります知っています)

お手伝いいただきありがとうございます

答えて

5

私はまったく同じトピックに関するブログ記事を書いていました。詳細については、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); 
    } 
} 
4

GmailのPOPaccessを提供します。だから、あなたはPOPを使ってコミュニケーションをとることができ、あなたは金色だよ。libraryを使ってください。

編集: IMAPに言及したことに気付きました。バルクダンプの代わりにPOPを使用することをお勧めします。 IMAPは、あなたがしたいことに対しては余りにも忙しいです。

IMAPを使用する必要がある場合は、a libraryをご利用ください。

0

https://github.com/jay0lee/got-your-back/wiki

しかし、Macユーザーはそれをコンパイルする必要があります(I避難所で(py2exeを使って)WindowsにコンパイルされたオープンソースのPythonプログラムがありますpy2exeエラーのために完全に理解できませんでした)。

どちらの方法でも、スケジュール内で自動的にプログラムを実行する方法が必要です。

関連する問題