管理篩選器
您可以使用篩選器為帳戶設定進階篩選規則。篩選器可根據傳入郵件的屬性或內容,自動新增或移除標籤,或將電子郵件轉寄至已驗證的別名。
如要瞭解如何建立、列出、取得或刪除篩選器,請參閱「篩選器參考資料」。
符合條件
您可以依寄件者、主旨、日期、大小和訊息內容等屬性篩選訊息。任何使用 Gmail 進階搜尋語法的查詢,也可以用於篩選器。舉例來說,常見的篩選器模式包括:
篩選器 |
配對組合 |
criteria.from='sender@example.com' |
來自 sender@example.com 的所有電子郵件 |
criteria.size=10485760
criteria.sizeComparison='larger' |
所有大小超過 10 MB 的電子郵件 |
criteria.hasAttachment=true |
所有含有附件的電子郵件 |
criteria.subject='[People with Pets]' |
主旨中含有字串 [People with Pets] 的所有電子郵件 |
criteria.query='"my important project"' |
所有包含 my important project 字串的電子郵件 |
criteria.negatedQuery='"secret knock"' |
所有不含 secret knock 字串的電子郵件 |
如果篩選器設有多個條件,則郵件必須符合所有條件,系統才會套用篩選器。
動作
您可以將動作套用至符合篩選條件的郵件。郵件可能會轉寄至已驗證的電子郵件地址,或是新增或移除標籤。
您可以新增或移除標籤,變更電子郵件的處理方式。舉例來說,常見的動作包括:
動作 |
效果 |
action.removeLabelIds=['INBOX'] |
封存電子郵件 (略過收件匣) |
action.removeLabelIds=['UNREAD'] |
標示為已讀取 |
action.removeLabelIds=['SPAM'] |
永不標示為垃圾內容 |
action.removeLabelIds=['IMPORTANT'] |
永不標示為重要 |
action.addLabelIds=['IMPORTANT'] |
標示為重要 |
action.addLabelIds=['TRASH'] |
刪除電子郵件 |
action.addLabelIds=['STARRED'] |
標示為已加星號 |
action.addLabelIds=['<user label id>'] |
使用者定義的標籤。每個篩選條件只能使用一個使用者定義的標籤。 |
範例
以下是更完整的範例,說明如何為郵寄清單中的訊息加上標籤並封存。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-01-15 (世界標準時間)。
[null,null,["上次更新時間:2025-01-15 (世界標準時間)。"],[[["Gmail Filters allow you to automatically sort, organize, and manage emails based on specific criteria such as sender, subject, keywords, and attachments."],["Filters can be configured to perform actions like adding or removing labels, forwarding to other addresses, archiving, deleting, or marking emails as important or read."],["You can use Gmail's advanced search operators to create complex filtering rules for precise email management."],["Filters help automate email workflows, saving time and ensuring important messages are handled appropriately."],["The Gmail API provides methods to programmatically create, modify, and delete filters for advanced integration and automation."]]],["Filters enable automatic email management based on message attributes or content. You can define criteria like sender, size, or subject, using advanced search syntax. Actions triggered by matching messages include forwarding and adding/removing labels. Common actions involve archiving, marking as read/important, or tagging with custom labels. The document shows how to create, list, get or delete filters. The examples show how to label and archive messages using Java and Python.\n"]]