メインコンテンツへスキップ

Outlookで特定のカテゴリを割り当てた後、指定したフォルダにメールを移動するにはどうすればよいですか?

Outlookで受信した電子メールにカテゴリを割り当てたとすると、カテゴリを割り当てた後、この電子メールをカテゴリ名で名前が付けられた特定の電子メールフォルダに自動的に移動します。 たとえば、カテゴリ「プライベート」が割り当てられた電子メールは、Outlookのフォルダ名「プライベート」に移動されます。 それを達成する方法は? この記事の方法は、問題を簡単に解決するのに役立ちます。

VBAで特定のカテゴリを割り当てた後、指定したフォルダにメールを移動します


VBAで特定のカテゴリを割り当てた後、指定したフォルダにメールを移動します

以下のVBAコードは、Outlookで特定のカテゴリを割り当てた後、指定したフォルダに電子メールを自動的に移動するのに役立ちます。 次のようにしてください。

1。 プレス 他の + F11 キーを押して アプリケーション向け Microsoft Visual Basic 窓。

2。 の中に アプリケーション向け Microsoft Visual Basic ウィンドウをダブルクリックして開きます ThisOutlookSession(コード) 窓。 次に、以下のVBAコードをウィンドウにコピーします。 スクリーンショットを参照してください:

VBAコード:特定のカテゴリを割り当てた後、指定したフォルダにメールを移動します

Private WithEvents xInboxFld As Outlook.Folder
Private WithEvents xInboxItems As Outlook.Items

Private Sub Application_Startup()
    Set xInboxFld = Outlook.Application.Session.GetDefaultFolder(olFolderInbox)
    Set xInboxItems = xInboxFld.Items
End Sub

Private Sub xInboxItems_ItemChange(ByVal Item As Object)
Dim xMailItem As Outlook.MailItem
Dim xFlds As Outlook.Folders
Dim xFld As Outlook.Folder
Dim xTargetFld As Outlook.Folder
Dim xFlag As Boolean
On Error Resume Next
If Item.Class = olMail Then
    Set xMailItem = Item
    xFlag = False
    If xMailItem.Categories <> "" Then
        Set xFlds = Application.Session.GetDefaultFolder(olFolderInbox).Folders
        If xFlds.Count <> 0 Then
            For Each xFld In xFlds
                If xFld.Name = xMailItem.Categories Then
                    xFlag = True
                End If
            Next
        End If
        If xFlag = False Then
            Application.Session.GetDefaultFolder(olFolderInbox).Folders.Add xMailItem.Categories, olFolderInbox
        End If
        Set xTargetFld = Application.Session.GetDefaultFolder(olFolderInbox).Folders(xMailItem.Categories)
        xMailItem.Move xTargetFld
    End If
End If
End Sub

3. コードを保存し、Outlook を再起動します。

4. 今後、受信メールにカテゴリを割り当てると、メールが移動された受信トレイ フォルダの下にカテゴリ名のフォルダが自動的に作成されます。スクリーンショットを参照してください。

Note:同じカテゴリが割り当てられたすべてのメールは、自動的に同じフォルダに移動さ​​れます。 ただし、電子メールに新しいカテゴリが割り当てられると、新しいフォルダーが自動的に作成されます。


関連記事:

最高のオフィス生産性向上ツール

🤖 Kutools AI アシスタント: 以下に基づいてデータ分析に革命をもたらします。 インテリジェントな実行   |  コードを生成  |  カスタム数式の作成  |  データを分析してグラフを生成する  |  Kutools関数を呼び出す...
人気の機能: 重複を検索、強調表示、または識別する   |  空白行を削除する   |  データを失わずに列またはセルを結合する   |   数式なしのラウンド ...
スーパールックアップ: 複数の基準の VLookup    複数の値の VLookup  |   複数のシートにわたる VLookup   |   ファジールックアップ ....
詳細ドロップダウン リスト: ドロップダウンリストを素早く作成する   |  依存関係のドロップダウン リスト   |  複数選択のドロップダウンリスト ....
列マネージャー: 特定の数の列を追加する  |  列の移動  |  Toggle 非表示列の表示ステータス  |  範囲と列の比較 ...
注目の機能: グリッドフォーカス   |  デザインビュー   |   ビッグフォーミュラバー    ワークブックとシートマネージャー   |  リソースライブラリ (自動テキスト)   |  日付ピッカー   |  ワークシートを組み合わせる   |  セルの暗号化/復号化    リストごとにメールを送信する   |  スーパーフィルター   |   特殊フィルター (太字/斜体/取り消し線をフィルター...) ...
上位 15 のツールセット12 テキスト ツール (テキストを追加, 文字を削除する、...)   |   50+ チャート 種類 (ガントチャート、...)   |   40+ 実用的 (誕生日に基づいて年齢を計算する、...)   |   19 挿入 ツール (QRコードを挿入, パスから画像を挿入、...)   |   12 変換 ツール (数字から言葉へ, 通貨の換算、...)   |   7 マージ&スプリット ツール (高度な結合行, 分割セル、...)   |   ... もっと

Kutools for Excel で Excel スキルを強化し、これまでにない効率を体験してください。 Kutools for Excelは、生産性を向上させ、時間を節約するための300以上の高度な機能を提供します。  最も必要な機能を入手するにはここをクリックしてください...

説明


Officeタブは、タブ付きのインターフェイスをOfficeにもたらし、作​​業をはるかに簡単にします

  • Word、Excel、PowerPointでタブ付きの編集と読み取りを有効にする、パブリッシャー、アクセス、Visioおよびプロジェクト。
  • 新しいウィンドウではなく、同じウィンドウの新しいタブで複数のドキュメントを開いて作成します。
  • 生産性を 50% 向上させ、毎日何百回もマウス クリックを減らすことができます!
Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Bonjour
je cherchais cette fonction depuis un moment pour classer mes mails.
Malheureusement ça ne fonctionne pas. J'ai outlook 2019 au boulot peut-être est-ce à cause de ça ? ou alors vu que je ne maitrise pas Virtual Basis ai-je fait une bêtise ?
Si quelqu'un peut m'(aider svp, je touche du doigt le graal mais il me manque de l'aide, svp....
Nico
This comment was minimized by the moderator on the site
I want to add more feature in this code. For instance, once email moved to business folder, I need this email to be automatically forward to specific email address. Possible?
This comment was minimized by the moderator on the site
it works as a charm but i want to take it to the next step. using a different folder instead of the inbox for example a folder called 2020 under the head and then from there the mentioned subfolders based on Categories. i was thinking to add this line.. Set xInboxFld = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).outlook.Application.Session.GetDefaultFolder(xMailItem.Categories)
This comment was minimized by the moderator on the site
worked on all mails not only after read. i created a rule mention a certain name that it gets a catergory. how can make it that it only takes the mails which are read?
This comment was minimized by the moderator on the site
This worked for me. would you be able to edit the code just to have the messages moved to one folder instead of creating one for each category. I have all the emails in one folder regardless of category and sort them in the folder.
This comment was minimized by the moderator on the site
At first this did not work for me either but after a while it just started to work, I'm not sure why though.
This comment was minimized by the moderator on the site
same here. Didn't work
This comment was minimized by the moderator on the site
Did not work.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations