0
1

More than 3 years have passed since last update.

outlook メール仕分けスクリプト

Last updated at Posted at 2019-10-31

概要

outlook 2010で、メール仕分けやってみた。

環境

windows7 32bit
outlook 2010

サンプルコード

Sub test()
    Dim NameSpc As Object
    Dim objbox As Object
    Dim fInbox As Object
    Dim jnkbox As Object
    Dim mail As Object
    Set NameSpc = Application.GetNamespace("MAPI")
    Set fInbox = NameSpc.GetDefaultFolder(olFolderInbox)
    Set jnkbox = NameSpc.GetDefaultFolder(olFolderJunk)
    MsgBox fInbox.Items.Count
    For i = fInbox.Items.Count To 1 Step -1
        Set mail = fInbox.Items(i)
        If InStr(mail.Subject, "一般") Then
            MsgBox mail.Subject
            mail.Move jnkbox
        End If
    Next
    Set mail = Nothing
    Set fInbox = Nothing
    Set NameSpc = Nothing
End Sub

VBエディタを起動

[ファイル] タブの [リボンのユーザー設定]> に移動します。
[リボンのユーザー設定] および [メイン タブ] の下の [開発] チェック ボックスをオンにします。

マクロが動くように

ファイル→オプション→セキュリティセンター→セキュリティセンターの設定→すべてのマクロに警告を表示するまたはすべてのマクロを有効にする

ワンクリックでマクロ起動

クイック アクセス ツール バーの右端の下向きの三角形をクリックします。
[その他のコマンド] をクリックします。
[コマンドの選択] で [マクロ] を選択します。

以上。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1