{"id":815,"date":"2024-05-22T09:48:18","date_gmt":"2024-05-22T00:48:18","guid":{"rendered":"https:\/\/dnetcore.ohwaki.jp\/wordpress\/?p=815"},"modified":"2024-05-22T12:47:45","modified_gmt":"2024-05-22T03:47:45","slug":"ms-graph-api%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f%e3%83%a1%e3%83%bc%e3%83%ab%e3%83%a1%e3%83%83%e3%82%bb%e3%83%bc%e3%82%b8%e6%a4%9c%e7%b4%a2%e3%81%a8%e5%89%8a%e9%99%a4","status":"publish","type":"post","link":"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=815","title":{"rendered":"MS Graph API\u3092\u4f7f\u7528\u3057\u305f\u30e1\u30fc\u30eb\u30e1\u30c3\u30bb\u30fc\u30b8\u691c\u7d22\u3068\u524a\u9664"},"content":{"rendered":"\n<p>ExchangeOnline\u4e0a\u3067\u7279\u5b9a\u306e\u9001\u4fe1\u8005\u304b\u3089\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u5168\u524a\u9664\u3057\u305f\u3044\u3068\u601d\u3044\u3001MS Graph\u3092\u4f7f\u7528\u3057\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u307f\u305f\u3002<\/p>\n\n\n\n<p>\u6700\u521d\u306f\u3001$filter\u3092\u4f7f\u7528\u3059\u308b\u3064\u3082\u308a\u3060\u3063\u305f\u304c\u3001\u30b7\u30f3\u30bf\u30c3\u30af\u30b9\u304c\u3088\u304f\u5206\u304b\u3089\u306a\u304f\u3066\u65ad\u5ff5\u3002\u3067\u3001\u8abf\u3079\u3066\u307f\u308b\u3068\u3001$filter\u3088\u308a$search\u306e\u65b9\u304c\u67d4\u8edf\u6027\u304c\u3042\u308a\u305d\u3046\u306a\u306e\u3067\u3001\u305d\u3061\u3089\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n\n\n\n<p>$search\u306e\u5bfe\u8c61\u3060\u304c\u3001\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u5834\u5408\u3001\u4e0b\u8a18\u306e\u7269\u3092\u691c\u7d22\u5bfe\u8c61\u3068\u3057\u3066\u4f7f\u7528\u3067\u304d\u308b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>attachment<\/strong><\/td><td>\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u540d<br>ex) attachment:.ppt<\/td><\/tr><tr><td><strong>bcc<\/strong><\/td><td>\u691c\u7d22\u5bfe\u8c61\u304cBcc\u5b9b\u5148\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3042\u308b\u3044\u306f\u6c0f\u540d\u306e\u30d5\u30eb\u6307\u5b9a\u307e\u305f\u306f\u4e00\u90e8<br>ex) bcc:xxx@yyy\u7b49<\/td><\/tr><tr><td><strong>body<\/strong><\/td><td>\u30e1\u30fc\u30eb\u30e1\u30c3\u30bb\u30fc\u30b8\u672c\u6587<br>ex) body:\u30c6\u30b9\u30c8<\/td><\/tr><tr><td><strong>cc<\/strong><\/td><td>\u691c\u7d22\u5bfe\u8c61\u304cCc \u6307\u5b9a\u65b9\u6cd5\u306fBcc\u540c\u69d8<br>ex) cc:xxx<\/td><\/tr><tr><td><strong>from<\/strong><\/td><td>\u691c\u7d22\u5bfe\u8c61\u304c\u9001\u4fe1\u5143 \u6307\u5b9a\u65b9\u6cd5\u306fBcc\u3068\u540c\u69d8<br>ex) from:xxx@yyy.com<\/td><\/tr><tr><td><strong>hasAttachment<\/strong><\/td><td>\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u6709\/\u7121(true\/false)<br>ex) hasAttachment:true<\/td><\/tr><tr><td><strong>importance<\/strong><\/td><td>\u91cd\u8981\u5ea6(low,midum,high)<br>ex) importance:high<\/td><\/tr><tr><td><strong>kind<\/strong><\/td><td>\u7a2e\u5225(docs,&nbsp;email,&nbsp;faxes,&nbsp;im,&nbsp;journals,&nbsp;meetings,&nbsp;notes,&nbsp;posts,&nbsp;rssfeeds,&nbsp;tasks, voicemail)<br>ex) kind:email<\/td><\/tr><tr><td><strong>participants<\/strong><\/td><td><strong>\u691c\u7d22\u5bfe\u8c61\uff1a<\/strong>to,&nbsp;cc, bcc(\u6307\u5b9a\u65b9\u6cd5\u306fbcc\u3068\u540c\u69d8)<\/td><\/tr><tr><td><strong>received<\/strong><\/td><td>\u691c\u7d22\u5bfe\u8c61\u306f\u53d7\u4fe1\u65e5\u4ed8<br>ex)<br>\u65e5\u4ed8\u6307\u5b9areceived:MM\/DD\/YYYY<br>\u7bc4\u56f2\u6307\u5b9areceived&gt;=MM\/DD\/YYYY\u3000AND received&lt;=MM\/DD\/YYYY<\/td><\/tr><tr><td><strong>recipients<\/strong><\/td><td>participants\u3068\u540c\u69d8<\/td><\/tr><tr><td><strong>sent<\/strong><\/td><td>\u691c\u7d22\u5bfe\u8c61\u306f\u9001\u4fe1\u65e5\u4ed8\u3002\u6307\u5b9a\u65b9\u6cd5\u306f\u53d7\u4fe1\u65e5\u4ed8\u3068\u540c\u69d8<\/td><\/tr><tr><td><strong>size<\/strong><\/td><td>\u691c\u7d22\u5bfe\u8c61\u306f\u30e1\u30c3\u30bb\u30fc\u30b8\u30b5\u30a4\u30ba(\u30d0\u30a4\u30c8\u6570)<br>ex)<br>size:1..5000<br>size&gt;=10000<\/td><\/tr><tr><td><strong>subject<\/strong><\/td><td>\u691c\u7d22\u5bfe\u8c61\u306f\u4ef6\u540d<br>ex) subject:\u30c6\u30b9\u30c8<\/td><\/tr><tr><td><strong>to<\/strong><\/td><td>\u691c\u7d22\u5bfe\u8c61\u306fTo \u6307\u5b9a\u65b9\u6cd5\u306f(bcc\u3068\u540c\u69d8)<br>ex) to:xxx@yyy.co.jp<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">\u691c\u7d22\u5bfe\u8c61\u3068\u6307\u5b9a\u65b9\u6cd5<\/figcaption><\/figure>\n\n\n\n<p>\u4e0a\u8a18\u306fAND\u3084OR\u306b\u3088\u3063\u3066\u7d50\u5408\u53ef\u80fd\u3002()\u3067\u512a\u5148\u9806\u4f4d\u306e\u5909\u66f4\u3082\u3067\u304d\u308b\u3002\u8a73\u3057\u304f\u306f\u4e0b\u8a18\u3092\u53c2\u7167\u3002<br><a href=\"https:\/\/learn.microsoft.com\/en-us\/graph\/search-query-parameter?tabs=csharp\">Use the $search query parameter in Microsoft Graph &#8211; Microsoft Graph | Microsoft Learn<\/a><br><a href=\"https:\/\/learn.microsoft.com\/en-us\/exchange\/policy-and-compliance\/ediscovery\/message-properties-and-search-operators?view=exchserver-2019\">Message properties and search operators for In-Place eDiscovery in Exchange Server | Microsoft Learn<\/a><\/p>\n\n\n\n<p>\u4f8b\uff09\u9001\u4fe1\u5143\u30c9\u30e1\u30a4\u30f3\u304cxxx.co.jp\u307e\u305f\u306fyyy.com\u30672024\/5\/10\u4ee5\u964d\u306b\u53d7\u4fe1\u3057\u305f\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u691c\u7d22<\/p>\n\n\n\n<p>&#8220;(from:xxx.co.jp OR from:yyy.com) AND received&gt;=05\/10\/2024&#8221;<\/p>\n\n\n\n<p>C#\u304b\u3089MS Graph API\u306b\u3053\u308c\u3089\u306e\u6761\u4ef6\u3092\u8a2d\u5b9a\u3059\u308b\u306b\u306f\u3001\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u53d6\u5f97\u6642\u306bQueryParamters.Search\u306b\u6e21\u3059\u5f62\u3068\u306a\u308b\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-csharp\" data-file=\"\u30e1\u30c3\u30bb\u30fc\u30b8\u691c\u7d22\" data-lang=\"C#\"><code>\/\/ Graph Client\u53d6\u5f97\nvar cli = new GraphServiceClient(cred);\n\u30fb\u30fb\u30fb\n\/\/\nstring query = $&quot;(from:{dom1} OR from:{dom2}) AND received&gt;={FromDate.ToString(&quot;MM\/dd\/yyyy&quot;)}&quot;;\n\/\/ \u30e1\u30fc\u30eb\u30e1\u30c3\u30bb\u30fc\u30b8\u691c\u7d22\nvar res = await cli.Me.Messages.GetAsync(\n    opt=&gt;{\n        opt.QueryParameters.Search = @$&quot;&quot;&quot;{query}&quot;&quot;&quot;;\n        opt.QueryParameters.Select = [&quot;id&quot;,&quot;sender&quot;,&quot;subject&quot;,&quot;receivedDateTime&quot;];\n        opt.QueryParameters.Top = 2000;\n    }\n);<\/code><\/pre><\/div>\n\n\n\n<p>\u3068\u3044\u3046\u611f\u3058\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u53d6\u5f97\u3057\u3066\u3001\u540c\u6642\u306b\u53d6\u5f97\u3057\u305f\u30e1\u30c3\u30bb\u30fc\u30b8\u306eId\u3092\u5229\u7528\u3057\u3066\u524a\u9664\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305f\u3002<\/p>\n\n\n\n<p>\u524a\u9664\u306fDeleteAsync\u3092\u4f7f\u7528\u3057\u3066\u884c\u306a\u3046\u3002\u4e00\u5fdc\u3001\u4e0b\u8a18\u306b\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u304a\u304f\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-csharp\" data-file=\"\u30e1\u30c3\u30bb\u30fc\u30b8\u524a\u9664\" data-lang=\"C#\"><code>foreach(var itm in res.Value) {\n    Console.WriteLine($&quot;{itm.Sender?.EmailAddress?.Address},{itm.Subject}&quot;);\n    await cli.Me.Messages[itm.Id].DeleteAsync();\n}<\/code><\/pre><\/div>\n\n\n\n<p>\u203bCLI\u3067\u8a66\u9a13\u5f8c\u3001Blazor\u3067\u30ed\u30b0\u30a4\u30f3\u21d2\u30e1\u30c3\u30bb\u30fc\u30b8\u691c\u7d22\uff0b\u9078\u629e\u524a\u9664\u306e\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u5fd8\u308c\u306a\u3044\u69d8\u306b\u30e1\u30e2\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ExchangeOnline\u4e0a\u3067\u7279\u5b9a\u306e\u9001\u4fe1\u8005\u304b\u3089\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u5168\u524a\u9664\u3057\u305f\u3044\u3068\u601d\u3044 &hellip; <a href=\"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=815\">\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,16,4],"tags":[],"class_list":["post-815","post","type-post","status-publish","format-standard","hentry","category-net","category-microsoft-graph","category-4"],"_links":{"self":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/815","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=815"}],"version-history":[{"count":5,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/815\/revisions"}],"predecessor-version":[{"id":820,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/815\/revisions\/820"}],"wp:attachment":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}