Notice: Constant SAVEQUERIES already defined in /home/uwsc/domains/uwsc.jp/public_html/wp-config.php on line 125

Notice: 関数 wp_add_inline_script が誤って呼び出されました。<script> タグを wp_add_inline_script() に渡さないでください。 詳しくは WordPress のデバッグをご覧ください。 (このメッセージはバージョン 4.5.0 で追加されました) in /home/uwsc/domains/uwsc.jp/public_html/wp-includes/functions.php on line 5905

Notice: Undefined variable: post in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 147

Notice: Undefined variable: post in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 154

Notice: Trying to get property 'ID' of non-object in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 154

Notice: Undefined index: description in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 200

Notice: Trying to access array offset on value of type null in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 200
Items.GetLast メソッド | UWSC辞典


Notice: Trying to access array offset on value of type null in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 27

Notice: Trying to access array offset on value of type null in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 31
Items.GetLast メソッド

本ページには広告が含まれています。


Notice: Undefined offset: 1 in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 188

Notice: Trying to access array offset on value of type null in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 13

Warning: in_array() expects parameter 2 to be array, string given in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 41

Notice: Undefined variable: id in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 61

Notice: Trying to access array offset on value of type null in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 27

Warning: in_array() expects parameter 2 to be array, null given in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 41

Notice: Undefined variable: html in /home/uwsc/domains/uwsc.jp/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(663) : eval()'d code on line 23

Itemsコレクションから最後の要素を取得します。

最初の要素を取得するには、Items.GetLast メソッドを使います。

構文
  1. Item = Items.GetLast
引数
戻り値

Items オブジェクトを返すメソッド・プロパティ

Items.Restrict メソッド
Items コレクションにフィルタを適用し、フィルタに一致する元のすべてのアイテムを含む新しいItems コレクションを返します。

使い方

既定フォルダにあるメールの最新のMailItem オブジェクトを取得。

受信日時を昇順(古い順)で並び替えた最後の要素なので、最新のメールとなります。

UWSC
CONST olFolderInbox = 6

DIM Outlook = CREATEOLEOBJ("Outlook.Application")
DIM NameSpace = Outlook.GetNameSpace("MAPI")
DIM Folder = NameSpace.GetDefaultFolder(olFolderInbox)
DIM Items = Folder.Items
Items.Sort("[ReceivedTime]", FALSE)
DIM MailItem = Items.GetLast

プログラム実行例

既定フォルダの最新のメールを取得

既定フォルダで受信した最新のメールを取得し、差出人名件名受信日時を出力します。

UWSC
CONST olFolderInbox = 6

DIM Outlook = CREATEOLEOBJ("Outlook.Application")
DIM NameSpace = Outlook.GetNameSpace("MAPI")
DIM Folder = NameSpace.GetDefaultFolder(olFolderInbox)

DIM Items = Folder.Items
Items.Sort("[ReceivedTime]", FALSE)
DIM MailItem = Items.GetLast

WITH MailItem
	PRINT "差出人名," + .SenderName
	PRINT "件名," + .Subject
	PRINT "受信日時," + .ReceivedTime
ENDWITH
使用関数

関連記事

Account オブジェクト
Accountオブジェクトは、現在のプロファイルに定義されているアカウントを表します。
Accounts オブジェクト
現在のプロファイルで利用できるアカウントを表すAccountオブジェクトのセットが含まれています。
Application オブジェクト
Outlookアプリケーション全体を表します。
AppointmentItem オブジェクト
新しい予定を表すAppointmentItemオブジェクトを作成します。
Folder オブジェクト
Folders オブジェクト
Items オブジェクト
MailItem オブジェクト
メールメッセージを表します。
NameSpace オブジェクト
Outlookのメールや予定表、連絡先といった様々なデータにアクセスすることができます。
Recipient オブジェクト