Office.AttachmentDetails interface
サーバーからのアイテムの添付ファイルを表します。 閲覧モードのみ。
AttachmentDetailsオブジェクトの配列は、予定またはメッセージ アイテムの attachments プロパティとして返されます。
注釈
最小アクセス許可レベル: 項目の読み取り
適用可能な Outlook モード: 読み取り
使用元
- Office.AppointmentRead: attachments
- Office.LoadedMessageRead: attachments
- Office.MessageRead: attachments
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachments-read.yaml
const item = Office.context.mailbox.item;
if (item.attachments.length > 0) {
for (let i = 0; i < item.attachments.length; i++) {
const attachment = item.attachments[i];
console.log(`${i+1}. Name: ${attachment.name}`);
console.log(`ID: ${attachment.id}`);
console.log(`Type: ${attachment.attachmentType}`);
console.log(`Inline content: ${attachment.isInline}`);
console.log(`Size: ${attachment.size}`);
}
} else {
console.log("This mail item doesn't contain any attachments.");
}
プロパティ
| attachment |
添付ファイルの種類を示す値を取得します。 |
| content |
インライン 添付ファイルのコンテンツ識別子を取得します。 |
| content |
添付ファイルの MIME コンテンツ タイプを取得します。
警告: |
| id | 添付ファイルの Exchange 添付ファイル ID を取得します。 ただし、添付ファイルの種類が |
| is |
添付ファイルが添付ファイル リストではなくアイテムの本文に画像として表示されるかどうかを示す値を取得します。 |
| name | 添付ファイルの名前を取得します。 |
| size | 添付ファイルのサイズをバイト単位で取得します。 |
プロパティの詳細
attachmentType
添付ファイルの種類を示す値を取得します。
attachmentType: MailboxEnums.AttachmentType | string;
プロパティ値
Office.MailboxEnums.AttachmentType | string
contentId
インライン 添付ファイルのコンテンツ識別子を取得します。
contentId: string;
プロパティ値
string
注釈
重要: 2025 年 11 月 15 日にリリースされた Outlook on the web および Windows 上の新しい Outlook の Outlook on the web の Outlook メールの HTML 本文でインライン画像が表示される方法が変更されました。 以前は、画像の添付ファイル ID は、該当する <img> 要素の src 属性に表示されていました。 代わりに、src 属性のコンテンツ ID (cid) によって画像が表されるようになりました。 HTML エディターから添付ファイル ID を解析する場合、または src 属性の URL から画像の Base64 でエンコードされた値を取得する場合は、アドインの解析ロジックを更新する必要があります。 詳細については、「Outlook on the web および新しい Outlook for Windows でのインライン画像表現の変更」を参照してください。
contentType
警告
この API は非推奨になりました。
If you require specific content types, grab the attachment's extension and process accordingly.
添付ファイルの MIME コンテンツ タイプを取得します。
警告: contentType 値は添付ファイルの拡張子の直接参照ですが、内部マッピングはアクティブに維持されないため、このプロパティは非推奨になりました。 特定のタイプが必要な場合は、添付ファイルの拡張機能を取得し、それに応じて処理します。 詳細については、関連するブログ記事を参照してください。
contentType: string;
プロパティ値
string
id
添付ファイルの Exchange 添付ファイル ID を取得します。 ただし、添付ファイルの種類が MailboxEnums.AttachmentType.Cloud の場合は、ファイルの URL が返されます。
id: string;
プロパティ値
string
isInline
添付ファイルが添付ファイル リストではなくアイテムの本文に画像として表示されるかどうかを示す値を取得します。
isInline: boolean;
プロパティ値
boolean
name
添付ファイルの名前を取得します。
name: string;
プロパティ値
string
注釈
重要: 添付ファイルの種類 Office.MailboxEnums.AttachmentType.Item は、 name プロパティでファイル名拡張子を返しません。
size
添付ファイルのサイズをバイト単位で取得します。
size: number;
プロパティ値
number