में ईमेल अनुलग्नक कैसे सहेजते हैं I सी # का उपयोग करके, मैं अपने मेल से एक ईमेल अनुलग्नक डाउनलोड कर सकता हूं (उदाहरण के लिए जीमेल)?सी #
Q
सी #
8
A
उत्तर
-3
निम्नलिखित कोड Extract Attachments sample से लिया गया है जो हमारे Rebex Mail घटक के साथ आता है। पीओपी 3 सर्वर से डाउनलोड करना HOWTO: Download emails from a GMail account in C# ब्लॉगपोस्ट में शामिल है।
// 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
मेरे पास 'अनुलग्नक' वर्ग में ऐसी विधियां और गुण नहीं हैं , क्या आपने कुछ तीसरे पक्षों का इस्तेमाल किया था? –
+1
मुझे पीओपी 3 क्लास लाइब्रेरी कहां मिल सकती है? –
और तुम हमें आप के लिए पूर्ण समाधान लिखना चाहते हैं? –
इस लिंक ने मुझे एक ही समस्या को हल करने में मदद की, लेकिन इसमें 30 दिन का परीक्षण है। http://www.example-code.com/csharp/pop3_saveAttachments.asp हैप्पी कोडिंग – Ravia
उत्तर के लिए कृपया देखें: http://pop3saveattachment.blogspot.in/ – Raj