{"id":694,"date":"2023-07-05T10:52:31","date_gmt":"2023-07-05T01:52:31","guid":{"rendered":"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=694"},"modified":"2023-07-05T10:53:40","modified_gmt":"2023-07-05T01:53:40","slug":"ms-graph%e3%81%a7%e3%83%a1%e3%83%bc%e3%83%ab%e9%80%81%e4%bf%a1","status":"publish","type":"post","link":"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=694","title":{"rendered":"MS Graph\u3067\u30e1\u30fc\u30eb\u9001\u4fe1"},"content":{"rendered":"\n<p>\u3053\u306e\u6240\u3001MS Graph\u306e\u8a71\u3070\u304b\u308a\u3068\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u304c\u3001\u4eca\u56de\u3082MS Graph\u306e\u304a\u8a71\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u3001\u30e1\u30fc\u30eb\u9001\u4fe1\u306b\u3064\u3044\u3066\u3002\u4eca\u307e\u3067\u3001\u3044\u304f\u3064\u304b\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u304d\u305f\u304c\u3001\u5927\u62b5\u3001MailKit.Net.Smtp\u3092\u4f7f\u7528\u3057\u4f5c\u6210\u3057\u3066\u3044\u305f\u3002<\/p>\n\n\n\n<p>MailKit.Net.Smtp\u3092\u4f7f\u7528\u3057\u3066\u3001Office365\u7d4c\u7531\u3067\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u5834\u5408\u306f\u3001Access Token\u3092\u53d6\u5f97\u5f8cSaslMechanismOAuth2\u3092\u4f5c\u6210\u3057\u3066\u3001\u8a8d\u8a3c\u3059\u308b\u308f\u3051\u3060\u304c\u3001\u7d50\u69cb\u9762\u5012\u3060\u3002<\/p>\n\n\n\n<p>\u8abf\u3079\u3066\u307f\u308b\u3068\u3001MS Graph\u3060\u3051\u3067\u3082\u30e1\u30fc\u30eb\u9001\u4fe1\u304c\u3067\u304d\u308b\u3088\u3046\u306a\u306e\u3067\u3001\u8a66\u3057\u3066\u307f\u305f\u3002<\/p>\n\n\n\n<p>Azure\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u5fc5\u8981\u306a\u6a29\u9650\u306f<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Mail.Send<\/li>\n<\/ul>\n\n\n\n<p>\u306e\u307f\u3002<\/p>\n\n\n\n<p>\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u4f5c\u6210\u5f8c\u3001\u3044\u3064\u3082\u306e\u3054\u3068\u304f\u3001MS Graph Client\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3057\u3066\u3001Me.SendMail.PostAsync\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3060\u3051\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-csharp\" data-file=\"\u30e1\u30fc\u30eb\u9001\u4fe1\u30b5\u30f3\u30d7\u30eb\" data-lang=\"C#\"><code>\/\/ MS Graph Client\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u4f5c\u6210\nvar cli = new GraphServiceClient(cred);\n\/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u4f5c\u6210\nvar mesg = new Microsoft.Graph.Me.SendMail.SendMailPostRequestBody() {\n    Message = new Message() {\n        Subject = &quot;\u30e1\u30fc\u30eb\u9001\u4fe1\u30c6\u30b9\u30c8&quot;,\n        Body = new ItemBody() {\n            ContentType = BodyType.Text,\n            Content = &quot;\u30e1\u30fc\u30eb\u9001\u4fe1\u3066\u3059\u3068\u3060\u3088\u3045&quot;\n        },\n\t\t\/\/ To\n        ToRecipients = new List&lt;Recipient&gt;() {\n            new Recipient() {\n                EmailAddress = new EmailAddress() {\n                    Address = &quot;boo@foo.com&quot;\n                }\n            }\n        },\n\t\t\/\/ Cc\n        CcRecipients = new List&lt;Recipient&gt;() {\n            new Recipient() {\n                EmailAddress = new EmailAddress() {\n                    Address = &quot;foo@woo.com&quot;\n                }\n            }\n        },\n\t\t\/\/ \u6dfb\u4ed8\n        Attachments = new List&lt;Attachment&gt;() {\n            new FileAttachment() {\n                Name = &quot;hoge.png&quot;,\n                ContentType = &quot;image\/png&quot;,\n                ContentBytes = buff\n            }\n        }\n    },\n    SaveToSentItems = true\n};\n\/\/ \u30e1\u30fc\u30eb\u9001\u4fe1\nawait cli.Me.SendMail.PostAsync(mesg);<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u6240\u3001MS Graph\u306e\u8a71\u3070\u304b\u308a\u3068\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u304c\u3001\u4eca\u56de\u3082MS Graph &hellip; <a href=\"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=694\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,9,16,4],"tags":[],"class_list":["post-694","post","type-post","status-publish","format-standard","hentry","category-net","category-c","category-microsoft-graph","category-4"],"_links":{"self":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=694"}],"version-history":[{"count":3,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/694\/revisions"}],"predecessor-version":[{"id":697,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/694\/revisions\/697"}],"wp:attachment":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}