{"id":9184,"date":"2018-05-30T09:49:18","date_gmt":"2018-05-30T00:49:18","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/?p=9184"},"modified":"2018-05-29T14:50:48","modified_gmt":"2018-05-29T05:50:48","slug":"openpop-net-%e3%82%92-xamarin-forms-%e3%81%a7%e4%bd%bf%e3%81%86","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/9184","title":{"rendered":"OpenPop.NET \u3092 Xamarin.Forms \u3067\u4f7f\u3046"},"content":{"rendered":"<p>\n\u5e38\u3005\u3001\u30b9\u30d1\u30e0\u30e1\u30fc\u30eb\u304c\u6ca2\u5c71\u3042\u3063\u3066\u30b9\u30de\u30db\u3067\u30e1\u30fc\u30eb\u304c\u53d7\u3051\u53d6\u308c\u306a\u3044\u306e\u306b\u30a4\u30e9\u30a4\u30e9\u3057\u3066\u3044\u308b\u8a33\u3060\u304c\u3002\u30b9\u30de\u30db\u3067\u95b2\u89a7\u3059\u308b\u3068\u304d\u306f\u3001\u5168\u3066\u3092\u53d7\u3051\u53d6\u308a\u305f\u3044\u306e\u3067\u306f\u306a\u304f\u3066\u91cd\u8981\u305d\u3046\u306a\uff08\u6700\u521d\u306b\u6c7a\u3081\u3089\u308c\u305f\u76f8\u624b\u3068\u304b\uff09\u30e1\u30fc\u30eb\u3060\u3051\u898b\u305f\u3044\u306e\u3067\u3001\u30b9\u30d1\u30e0\u3082\u305d\u3046\u3060\u3051\u3069\u5e83\u544a\u30e1\u30fc\u30eb\u3082\u5916\u3057\u305f\u304b\u3063\u305f\u308a\u3059\u308b\u3002\u3044\u308f\u3086\u308b\u3001\u81ea\u5206\u306a\u308a\u306e\u30db\u30ef\u30a4\u30c8\u30ea\u30b9\u30c8\u304c\u4f5c\u3063\u3066\u304a\u304d\u305f\u3044\u3002\n<\/p>\n<p>\n\u3064\u307e\u308a\u306f\u81ea\u524d\u306e\u30e1\u30fc\u30e9\u30fc\u30a2\u30d7\u30ea\u304c\u3042\u308c\u3070\u3044\u3044\u306e\u3060\u3051\u3069\u3001\uff08\u78ba\u304b\uff09iOS\u306e\u5834\u5408\u306f\u898f\u7d04\u4e0a\u4f5c\u308c\u306a\u3044\u306e\u3067\u30b9\u30c8\u30a2\u306b\u306f\u51fa\u3066\u6765\u306a\u3044\u3002<br \/>\n\u306a\u3089\u3070\u3001\u4f5c\u308c\u3070\u3044\u3044\u3060\u308d\u3046\u3001\u3068\u3044\u3046\u3053\u3068\u3002\n<\/p>\n<p><h2>OpenPop.NET<\/h2>\n<\/p>\n<p>\n\u7c21\u5358\u306aPOP3\u306e\u5b9f\u88c5\u306a\u3089\u3070\u305d\u308c\u307b\u3069\u96e3\u3057\u304f\u306f\u306a\u3044\u306e\u3060\u3051\u3069\u3001\u3067\u304d\u308b\u306a\u3089\u3070\u65e2\u306b\u5b9f\u7e3e\u304c\u3042\u308b\u3082\u306e\u304c\u3088\u3044\u3002\n<\/p>\n<p>\nOpenPop.NET &#8211; Robust POP3 client and MIME parser written in C#<br \/>\n<a href=\"http:\/\/hpop.sourceforge.net\/\">http:\/\/hpop.sourceforge.net\/<\/a>\n<\/p>\n<p>\n\u3069\u3046\u3084\u3089 .NET Framework 2.0 \u306e\u9803\u304b\u3089\u3042\u308b\u53e4\u3044\u5b9f\u88c5\u306a\u306e\u3060\u3051\u3069\u3001\u30b5\u30f3\u30d7\u30eb\u3082\u3042\u308b\u306e\u3067\u305d\u306e\u307e\u307e\u4f7f\u3048\u305d\u3046\u3002\n<\/p>\n<p>\n\u3063\u3066\u306a\u308f\u3051\u3067\u3001.NET Standard 2.0 \u3067\u30d3\u30eb\u30c9\u3057\u76f4\u3057\u3066\u307f\u308b\u3001\u3068\n<\/p>\n<p>\nmoonmile\/hpop: OpenPOP.NET code repository<br \/>\n<a href=\"https:\/\/github.com\/moonmile\/hpop\">https:\/\/github.com\/moonmile\/hpop<\/a>\n<\/p>\n<p>\n\u3042\u3063\u3055\u308a\u3067\u304d\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u3001\u3053\u308c\u3092 Xamarin.Forms \u306b\u7d44\u307f\u8fbc\u3080\u3002\n<\/p>\n<p><h2>Xamarin.Forms+OpenPop.NET<\/h2>\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing OpenPop.Pop3;\nusing System.Net.Mail;\n\npublic partial class MainPage : ContentPage\n{\n\tpublic MainPage()\n\t{\n\t\tInitializeComponent();\n        this.LayoutChanged += MainPage_LayoutChanged;\n\t}\n\n    private void MainPage_LayoutChanged(object sender, EventArgs e)\n    {\n        var client = new Pop3Client();\n        client.Connect(&quot;\u30db\u30b9\u30c8\u540d&quot;, 110, false);\n        client.Authenticate(\n            &quot;\u30e6\u30fc\u30b6\u30fc\u540d&quot;, \n            &quot;\u30d1\u30b9\u30ef\u30fc\u30c9&quot;, \n            AuthenticationMethod.UsernameAndPassword);\n        int messageCount = client.GetMessageCount();\n\n        var items = new List&lt;MailMessage&gt;();\n        int cnt = 0;\n        for ( int i = messageCount; i&gt;0; i--  )\n        {\n            \/\/\/ 30 \u4ef6\u3067\u533a\u5207\u308b\n            if (cnt++ &gt;= 30) break;\n\n            try\n            {\n                var msg = client.GetMessage(i);\n                if (msg != null)\n                    items.Add(msg.ToMailMessage());\n            }\n            catch { }\n        }\n        this.lv.ItemsSource = items;\n\n    }\n}\n<\/pre>\n<p>\n\u9014\u4e2d\u3067 try-catch \u3057\u3066\u3044\u308b\u306e\u306f\u3001Form \u306e\u30b3\u30fc\u30c9\u5909\u63db\u3042\u305f\u308a\u3067\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3044\u308b\u304b\u3089\u3002\u30c7\u30b3\u30fc\u30c9\u304c\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u3088\u3046\u306a\u306e\u3067\u3001ToMailMessage\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u88c5\u306f\u81ea\u524d\u3067\u884c\u3063\u305f\u307b\u3046\u304c\u3088\u3044\u304b\u3082\u3057\u308c\u306a\u3044\uff08\u65e5\u672c\u8a9e\u306e\u30b3\u30fc\u30c9\u5909\u63db\u3060\u304b\u3089\u3060\u308d\u3046\uff09\u3002\n<\/p>\n<p>\n\u3072\u3068\u307e\u305a\u3001ListView \u306b\u30d0\u30a4\u30f3\u30c9\u3055\u305b\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308b\u3002\n<\/p>\n<p><a href='http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2018\/05\/dworkblogimage20180529_01org.jpg'><img border='0' src='http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2018\/05\/dworkblogimage20180529_01thum.jpg'\/><\/a><\/p>\n<p><h2>\u3069\u3046\u3084\u3063\u3066\u4f7f\u3046\u304b\uff1f<\/h2>\n<\/p>\n<p>\n\u3061\u3083\u3093\u3068\u3057\u305f\u30e1\u30fc\u30e9\u30fc\u30a2\u30d7\u30ea\u6a19\u6e96\u306e\u3082\u306e\u3092\u4f7f\u3046&#8230;\u3068\u3044\u3046\u304b\u6a19\u6e96\u306e\u3057\u304b\u4f7f\u3048\u306a\u3044\u306e\u3067\u3001\u307e\u308b\u3063\u304d\u308a\u81ea\u4f5c\u30a2\u30d7\u30ea\u3068\u3057\u3066\u4f7f\u3046\u3002\u30b9\u30de\u30db\u306e\u30e1\u30fc\u30e9\u30fc\u306f\u632f\u308a\u5206\u3051\u304c\u8ca7\u5f31\u306a\u306e\u3067\u3001\u305d\u306e\u3042\u305f\u308a\u3092\u88dc\u3048\u3070\u3044\u3044\u3002\n<\/p>\n<ul>\n<li>From \u3092\u898b\u3066\u3001\u7279\u5b9a\u306e\u4eba\u3060\u3051\u3092\u8868\u793a\u3055\u305b\u308b<\/li>\n<li>Subject \u306b\u7279\u5b9a\u306e\u6587\u5b57\u304c\u3067\u3066\u304d\u305f\u3082\u306e\u306e\u307f\u8868\u793a\u3055\u305b\u308b\u3002<\/li>\n<\/ul>\n<p>\n\u306a\u611f\u3058\u3067\u3044\u3044\u3060\u308d\u3046\u3002\u8fd4\u4fe1\u3059\u308b\u3068\u304d\u306f\u30b3\u30d4\u30da\u3057\u3066\u304b\u3089\u6a19\u6e96\u30a2\u30d7\u30ea\u306b\u53d7\u3051\u6e21\u305b\u3070\u3044\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5e38\u3005\u3001\u30b9\u30d1\u30e0\u30e1\u30fc\u30eb\u304c\u6ca2\u5c71\u3042\u3063\u3066\u30b9\u30de\u30db\u3067\u30e1\u30fc\u30eb\u304c\u53d7\u3051\u53d6\u308c\u306a\u3044\u306e\u306b\u30a4\u30e9\u30a4\u30e9\u3057\u3066\u3044\u308b\u8a33\u3060\u304c\u3002\u30b9\u30de\u30db\u3067\u95b2\u89a7\u3059\u308b\u3068\u304d\u306f\u3001\u5168\u3066\u3092\u53d7\u3051\u53d6\u308a\u305f\u3044\u306e\u3067\u306f\u306a\u304f\u3066\u91cd\u8981\u305d\u3046\u306a\uff08\u6700\u521d\u306b\u6c7a\u3081\u3089\u308c\u305f\u76f8\u624b\u3068\u304b\uff09\u30e1\u30fc\u30eb\u3060\u3051\u898b\u305f\u3044\u306e\u3067\u3001\u30b9\u30d1\u30e0\u3082\u305d\u3046\u3060\u3051\u3069\u5e83 &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/9184\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,23,62],"tags":[],"class_list":["post-9184","post","type-post","status-publish","format-standard","hentry","category-dev","category-csharp","category-xamarin"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/9184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=9184"}],"version-history":[{"count":1,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/9184\/revisions"}],"predecessor-version":[{"id":9185,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/9184\/revisions\/9185"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=9184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=9184"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=9184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}