首页 > 解决方案 > Outlook 附件计数

问题描述

我正在编写一些代码来保存 Outlook 电子邮件,我需要知道附件的数量。要获得附件计数,请使用此代码。当没有附件时,nAttach 为 0,但当有 n 个附件时,我得到 n+1。我尝试使用 nAttach -1 对其进行更正,但随后又出现了问题,或者有时如果我有 1 个附件,它会变为 0。

  Dim oMail As Outlook.MailItem
  Dim sAttach As String
  Dim nAttach As Integer
     
  nAttach = oMail.Attachments.Count
  If nAttach > 0 Then nAttach = nAttach - 1
  sAttach = CStr(nAttach)

标签: vbaoutlook

解决方案


附件计数很可能是正确的。请注意,即使 Outlook 未在附件列表中显示嵌入的 HTML 图像,它们也可以是附件。


推荐阅读