Outlook.MailItem.DownloadState属性的定义及用途解析咨询
Hey there! Let me break down the Outlook.MailItem.DownloadState property for you clearly—since I know official docs can feel a bit abstract sometimes.
What is
Outlook.MailItem.DownloadState? This property is part of the Outlook Object Model, and its core job is to tell you the current download status of a specific email (MailItem). In plain terms, it answers: Is this email fully saved to my local device, only partially downloaded, or not downloaded at all?
Possible Values (And What They Mean)
It uses the OlDownloadState enum, so you’ll see these three common values:
olFullDownload(value = 1): The entire email—body, attachments, all metadata—is downloaded locally. You can access it fully even when offline, and there’s no need for Outlook to fetch anything from the server to view it.olPartialDownload(value = 2): Only the email header (sender, subject, receive time, etc.) is stored locally. The actual body content and attachments still live on the mail server. If you open this email, Outlook will automatically download the remaining content in the background. This is super common with cached Exchange mode (when you set it to sync only recent emails) or IMAP accounts configured to sync headers first.olNoDownload(value = 0): The email hasn’t been downloaded at all—your Outlook only has a placeholder for it, with no local content. You’ll need an active server connection to fetch any part of it.
Practical Uses for This Property
Why would you care about this? Here are some real-world scenarios:
- Offline access checks: If you’re building an Outlook add-in or automation script, you can use this property to confirm if an email is usable offline. Only
olFullDownloaditems work without a server connection. - Avoid errors in batch operations: Suppose you want to loop through emails and extract attachments—you’ll want to filter for
olFullDownloadfirst. Trying to access attachments on a partially downloaded email will throw errors because those files aren’t local yet. - Basic status monitoring: While it doesn’t give you a percentage progress bar, you can track when an email transitions from
olNoDownload→olPartialDownload→olFullDownloadto give users simple status updates in custom tools.
Quick VBA Example
Here’s a simple script to check the download state of the selected email in Outlook:
Sub CheckEmailDownloadStatus() Dim selectedMail As Outlook.MailItem ' Make sure an email is selected If Application.ActiveExplorer.Selection.Count = 0 Then MsgBox "Please select an email first!" Exit Sub End If Set selectedMail = Application.ActiveExplorer.Selection.Item(1) Select Case selectedMail.DownloadState Case olFullDownload MsgBox "✅ This email is fully downloaded locally. You can access it offline!" Case olPartialDownload MsgBox "⚠️ Only the email header is downloaded. Body/attachments are on the server." Case olNoDownload MsgBox "❌ This email hasn't been downloaded yet. You need an internet connection to view it." End Select End Sub
内容的提问来源于stack exchange,提问作者Willy
相关产品推荐
相关产品推荐

