Outlook 附件计数显示不正确的数字

米库

我试图遍历所选邮件中的所有附加项目,但附件计数产生了荒谬的价值。

Sub ABU_out()

Dim olapp As Outlook.Application
Dim olmail As Outlook.MailItem
Dim item As Object
Dim olath As Outlook.Attachments




Set olapp = GetObject(, "Outlook.Application")
Set olmail = olapp.ActiveExplorer.Selection(1)


If Not olmail.Attachments.Count = 0 Then

Debug.Print olmail.Attachments.Count

        For Each olath In olmail.Attachments

            If InStr(LCase(olath.FileName), "certificate") Then

                If InStr(LCase(olath.FileName), "endorsement") = 0 Then

                    Debug.Print olath.FileName

                    olath.SaveAsFile "C:\Users\mohit.bansal\Desktop\Automations\ABU\Slips Sample\" & olath.FileName

                End If

            End If

        Next

End If



End Sub

当我选择一封包含 2 个项目的邮件时出现问题,“debug.print”说 3,如果邮件有 3 个项目,它说 5。错误出现在 olath 说它什么都没有不确定代码中有什么问题,我使用了类似的代码在运作顺利的私人活动中。

米库

发现错误.... 我将olath 声明为outlook.attachments 而如果我将其声明为对象,则它可以工作。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章