0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【VBA】Outlookの受信メールの件数を取得

Last updated at Posted at 2024-02-04

以下のような内容でVBEに記述していく。

Sub GetMail()

'Outlookを操作するインスタンス取得
Dim oApp As New Outlook.Application

'Outlook の NameSpace オブジェクトを取得
Dim oNs As Outlook.Namespace
Set oNs = oApp.GetNamespace("MAPI")

'受信トレイフォルダーを取得
Dim oF As Folder
Set oF = oNs.Folders("任意のプロファイル").Folders("フォルダ名")

MsgBox oF.Items.Count

End Sub

実行すると、メッセージボックスで件数が表示される。

スクリーンショット 2024-02-04 221507.png
スクリーンショット 2024-02-05 033831.png
スクリーンショット 2024-02-05 033956.png
スクリーンショット 2024-02-05 034139.png
スクリーンショット 2024-02-05 034255.png
スクリーンショット 2024-02-05 034354.png

スクリーンショット 2024-02-05 034439.png
スクリーンショット 2024-02-05 034512.png

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?