--- title: "sysmail_mailattachments (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "03/06/2017" ms.prod: "sql-non-specified" ms.reviewer: "" ms.suite: "" ms.technology: - "database-engine" ms.tgt_pltfrm: "" ms.topic: "language-reference" f1_keywords: - "sysmail_mailattachments_TSQL" - "sysmail_mailattachments" dev_langs: - "TSQL" helpviewer_keywords: - "sysmail_mailattachments database mail view" ms.assetid: aee87059-a4c1-459a-a95c-641b4e3f0e73 caps.latest.revision: 14 author: "JennieHubbard" ms.author: "jhubbard" manager: "jhubbard" --- # sysmail_mailattachments (Transact-SQL) [!INCLUDE[tsql-appliesto-ss2008-xxxx-xxxx-xxx_md](../../includes/tsql-appliesto-ss2008-xxxx-xxxx-xxx-md.md)] Contains one row for each attachment submitted to Database Mail. Use this view when you want information about Database Mail attachments. To review all e-mails processed by Database Mail use [sysmail_allitems (Transact-SQL)](../../relational-databases/system-catalog-views/sysmail-allitems-transact-sql.md). |Column name|Data type|Description| |-----------------|---------------|-----------------| |**attachment_id**|**int**|Identifier of the attachment.| |**mailitem_id**|**int**|Identifier of the mail item that contained the attachment.| |**filename**|**nvarchar(520)**|The file name of the attachment. When **attach_query_result** is 1 and **query_attachment_filename** is NULL, Database Mail creates an arbitrary filename.| |**filesize**|**int**|The size of the attachment in bytes.| |**attachment**|**varbinary(max)**|The content of the attachment.| |**last_mod_date**|**datetime**|The date and time of the last modification of the row.| |**last_mod_user**|**sysname**|The user who last modified the row.| ## Remarks When troubleshooting Database Mail, use this view to see the properties of the attachments. Attachments stored in the system tables can cause the **msdb** database to grow. Use **sysmail_delete_mailitems_sp** to delete mail items and their associated attachments. For more information, see [Create a SQL Server Agent Job to Archive Database Mail Messages and Event Logs](../../relational-databases/database-mail/create-a-sql-server-agent-job-to-archive-database-mail-messages-and-event-logs.md). ## Permissions Granted to the **sysadmin** fixed server role and the **DatabaseMailUserRole** database role. When executed by a member of the **sysadmin** fixed server role, this view shows all attachments. All other users only see the attachments for messages that they submitted. ## See Also [sysmail_allitems (Transact-SQL)](../../relational-databases/system-catalog-views/sysmail-allitems-transact-sql.md) [sysmail_faileditems (Transact-SQL)](../../relational-databases/system-catalog-views/sysmail-faileditems-transact-sql.md) [sysmail_sentitems (Transact-SQL)](../../relational-databases/system-catalog-views/sysmail-sentitems-transact-sql.md) [sysmail_unsentitems (Transact-SQL)](../../relational-databases/system-catalog-views/sysmail-unsentitems-transact-sql.md) [sysmail_event_log (Transact-SQL)](../../relational-databases/system-catalog-views/sysmail-event-log-transact-sql.md)