2010-01-11 8 views
8

Nasıl C# kullanarak, Postamdan bir e-posta eki indirebilirim (örneğin gmail)?C# ekleriyle ilgili e-posta eklerini kaydetme C#

+9

Ve bize senin için komple bir çözüm yazmak ister misin? –

+0

Bu bağlantı aynı sorunu çözmemde bana yardımcı oldu, ancak bu 30 günlük deneme süresine sahip. http://www.example-code.com/csharp/pop3_saveAttachments.asp Mutlu kodlama – Ravia

+0

Lütfen ans için http://pop3saveattachment.blogspot.in/ – Raj

cevap

-3

Aşağıdaki kod, Rebex Mail bileşenle gelen Extract Attachments sample numaralı telefondan alınmıştır. Bir POP3 sunucusundan indirme, HOWTO: Download emails from a GMail account in C# blog yayınında yer almaktadır.

// Load mail message from disk 
MailMessage mail = new MailMessage(); 
mail.Load (args[0]); 

Console.WriteLine (
    "Message contains {0} attachments.", 
    mail.Attachments.Count 
); 

// If message has no attachments, just exit 
if (mail.Attachments.Count == 0) 
    return 0; 

foreach (Attachment attachment in mail.Attachments) 
{ 
    // Save the file 
    Console.WriteLine ("Saving '{0}' ({1}).", 
    attachment.FileName, attachment.MediaType); 
    attachment.Save (attachment.FileName); 
} 
0
// Firstly you might want to use POP3Class which is mail support class. 

    POP3Class Pop3= new POP3Class(); 
    pop3.DoConnect("your.mail.server",110,"username","password"); 
    pop3.GetStat(); 


    // and then you can use the below code for storing an attachment. 

    MailMessage mail = new MailMessage(); 
    Mail.Load (args[0]); 

    Console.WriteLine (
    "Message contains {0} attachments.", 
    mail.Attachments.Count 
    ); 

    // If message has no attachments, just exit 
    if (mail.Attachments.Count == 0) 
    return 0; 

    foreach (Attachment attachment in mail.Attachments) 
    { 
    // Save the file 
    Console.WriteLine ("Saving '{0}' ({1}).", 
    attachment.FileName, attachment.MediaType); 
    attachment.Save (attachment.FileName); 
    } 


// Hope that helps. 
+0

'Eklenti' sınıfında bu tür yöntemlere ve özelliklere sahip değilim. , bazı üçüncü taraflar libs kullandın mı? –

+1

POP3Class kitaplığını nereden alabilirim? –