# 特定の条件からメールを取得する方法について

**URL:** <https://forum.uipath.com/t/topic/775952>\
**Category:** Studio\
**Tags:** studio, mail, activities\
**Created:** [October 27, 2024, 10:59pm UTC](https://forum.uipath.com/t/topic/775952 "2024-10-27T22:59:08Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![once10201029](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/once10201029/32/499873_2.png) [@once10201029](https://forum.uipath.com/u/once10201029)\
**Post date:** [October 27, 2024, 10:59pm UTC](https://forum.uipath.com/t/topic/775952/1 "2024-10-27T22:59:08Z")

</div>

受信トレイのメール欄から以下条件に沿ってメールを取得したいです。

 ![image](https://global.discourse-cdn.com/uipath/original/4X/5/c/d/5cd906ed50ffec571e43c4e71310992b8dd5938d.png)

2枚目の様に件名と本文を取得してからスタートだと思っているのですが、  
『』のように特定の文字で取得する際どのように繋がっていくのでしょうか？

 ![The image shows a workflow in a Japanese version of Microsoft Power Automate, where email messages from Outlook are being processed in a series of loops to extract and store subject and body data. (Captioned by AI)](https://global.discourse-cdn.com/uipath/original/4X/2/8/7/287f664e063b22827f79de73a59f6c169642126c.png)

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [October 27, 2024, 11:25pm UTC](https://forum.uipath.com/t/topic/775952/2 "2024-10-27T23:25:53Z")

</div>

こんにちは

まず③はOutlookメールメッセージ取得アクティビティのプロパティで設定する必要があります。  
①②についてはOutlookメールメッセージ取得アクティビティのフィルターを使うか、繰り返しアクティビティやLINQ等で必要なものを処理するようにします。  
繰り返しアクティビティは基本的に一つで十分です。（内部で条件分岐を行い、必要なもののみを処理すれば良いかと思います。）

以下公式ドキュメントも参考になると思います（フィルター等）

> **[アクティビティ - Outlook メール メッセージを取得](https://docs.uipath.com/ja/activities/other/latest/productivity/get-outlook-mail-messages)**
>
> The UiPath Documentation Portal - the home of all our valuable information. Find here everything you need to guide you in your automation journey in the UiPath ecosystem, from complex installation guides to quick tutorials, to practical business...

---

<div class="post-metadata">

**Author:** ![once10201029](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/once10201029/32/499873_2.png) [@once10201029](https://forum.uipath.com/u/once10201029)\
**Post date:** [October 28, 2024, 12:54am UTC](https://forum.uipath.com/t/topic/775952/3 "2024-10-28T00:54:25Z")

</div>

回答ありがとうございます。  
共有PCにて作成しているため現在試せないのですが、今回でいうとフィルターしたいものが①と②で2つあるため、Outlookメールメッセージ取得アクティビティが2個必要になるんでしょうか？それとも1つのアクティビティ対して複数フィルターをかけることができるんでしょうか？

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [October 28, 2024, 1:04am UTC](https://forum.uipath.com/t/topic/775952/4 "2024-10-28T01:04:14Z")

</div>

> [@once10201029](#):
>
> それとも1つのアクティビティ対して複数フィルターをかけることができるんでしょうか？

JET構文、DASL構文ともANDが使えますので、一つのアクティビティで実現します。（異なる構文を組み合わせることはできませんので、その点は注意ください）

---

<div class="post-metadata">

**Author:** ![once10201029](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/once10201029/32/499873_2.png) [@once10201029](https://forum.uipath.com/u/once10201029)\
**Post date:** [October 28, 2024, 2:21am UTC](https://forum.uipath.com/t/topic/775952/5 "2024-10-28T02:21:24Z")

</div>

![The image shows a UiPath Studio workflow using the "Get Outlook Mail Messages" activity with a filter set to check for emails containing specific Japanese text strings. (Captioned by AI)](https://global.discourse-cdn.com/uipath/original/4X/b/1/7/b179aea046a4c66b5cc4ab0da521a4865838a763.png)  
書き方としては以上のようなイメージでしょうか？

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [October 28, 2024, 2:25am UTC](https://forum.uipath.com/t/topic/775952/6 "2024-10-28T02:25:00Z")

</div>

違います。上記のアクティビティパッケージの説明ページの下方にフィルターの例があるのでこちら参照＆実機でお試しください。含まれる条件なのでDASL構文（`@SQL`で始まる方の構文）が必要かと思います。

---

<div class="post-metadata">

**Author:** ![once10201029](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/once10201029/32/499873_2.png) [@once10201029](https://forum.uipath.com/u/once10201029)\
**Post date:** [October 28, 2024, 2:44am UTC](https://forum.uipath.com/t/topic/775952/7 "2024-10-28T02:44:24Z")

</div>

ありがとうございます。  
このような指定方法があること初めて知ることができました。

 ![The image shows text code written in SQL, presented in what appears to be a search bar, including a mix of English and Chinese characters, and dealing with email subjects and descriptions based on specific keywords. (Captioned by AI)](https://global.discourse-cdn.com/uipath/original/4X/e/0/f/e0fa1791804b2c6fe7d4e8e99c99b32a2044300d.png)  
自分なりに例を見て書いてみたんですが、これで動かした際エラーがでてしまいました。&でつなげてはいけないんでしょうか、、、

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [October 28, 2024, 3:00am UTC](https://forum.uipath.com/t/topic/775952/8 "2024-10-28T03:00:53Z")

</div>

> [@once10201029](#):
>
> &でつなげてはいけないんでしょうか、、、

`&`はVb.netでの文字列結合演算子ですので、DASL構文上の論理積条件とは異なります。

例えば以下の様に記述する必要があります。

```
"@SQL= urn:schemas:httpmail:subject like '%KEYWORD1%' AND urn:schemas:httpmail:textdescription like '%KEYWORD2%'"

```

---

<div class="post-metadata">

**Author:** ![once10201029](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/once10201029/32/499873_2.png) [@once10201029](https://forum.uipath.com/u/once10201029)\
**Post date:** [October 28, 2024, 3:56am UTC](https://forum.uipath.com/t/topic/775952/9 "2024-10-28T03:56:59Z")

</div>

ありがとうございます。  
【登録完了通知】や【品番新規登録】などが記載しているメールは、現時点でRPAを動かす端末に直接届いているわけではなく、転送するしかないのですが、別の人から転送した場合でも適用されますでしょうか？(動作テストがうまくいくか)

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [October 28, 2024, 3:59am UTC](https://forum.uipath.com/t/topic/775952/10 "2024-10-28T03:59:58Z")

</div>

差は無いと思いますが、聞くより試した方が早いと思いますよ。

---

<div class="post-metadata">

**Author:** ![once10201029](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/once10201029/32/499873_2.png) [@once10201029](https://forum.uipath.com/u/once10201029)\
**Post date:** [October 28, 2024, 4:08am UTC](https://forum.uipath.com/t/topic/775952/11 "2024-10-28T04:08:42Z")

</div>

失敗していたのですが、転送確認時に既読になっていたことが原因でした。  
無事メッセージボックスでも上手く返ってきました！  
大変助かりました！ありがとうございます！

---

<div class="post-metadata">

**Author:** ![once10201029](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/once10201029/32/499873_2.png) [@once10201029](https://forum.uipath.com/u/once10201029)\
**Post date:** [October 28, 2024, 4:27am UTC](https://forum.uipath.com/t/topic/775952/12 "2024-10-28T04:27:48Z")

</div>

![image](https://global.discourse-cdn.com/uipath/original/4X/d/0/5/d05a5f10e311912b16349fcbc5d02ebae3a3ab11.png)

追記で失礼いたします。  
このままの流れで outlookメールメッセージを取得アクティビティにて出力しているmsgDat(変数)を使って

msgDat = True で分岐が完了だと思っていたのですが、List型なのでエラーが出てしまいました。型を変更アクティビティを使いboolean型にして以下の様にしてみたのですが型を変更出来ないエラーが出てしまう始末です。。。

条件式の際は基本的にboolean変数のものしか使ったことがないのですが  
LIst型のままエラーが出ない条件式を書くことは可能なのでしょうか？

 ![This image shows a flowchart in Japanese, where a variable is being converted to a Boolean type and then conditionally checked if it is true, with placeholder sections for subsequent actions. (Captioned by AI)](https://global.discourse-cdn.com/uipath/original/4X/9/e/7/9e7967def8a4c2a6c26864deb01139bf3cc5c9d4.png)

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [October 28, 2024, 4:44am UTC](https://forum.uipath.com/t/topic/775952/13 "2024-10-28T04:44:55Z")

</div>

> [@once10201029](#):
>
> 追記で失礼いたします。

基本的にタイトルから離れる話題は別トピックにいただいた方が良いです。

 ![image](https://global.discourse-cdn.com/uipath/original/4X/a/b/2/ab2facd72812d34c8765127d8a97ab6ccc6009de.png)

List型変数の中身が空かどうかを判断するには

```
varList.Any()

```

あるいは

```
varList.Count>0

```

等が使えると思います。

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [October 31, 2024, 4:45am UTC](https://forum.uipath.com/t/topic/775952/14 "2024-10-31T04:45:20Z")

</div>

Closed on October 31, 2024, 4:45am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
