我有一個VBA腳本,用於將郵件歸檔到個人文件夾。它在正常消息上正常工作,但每次遇到已加密的消息時,都會發出運行時錯誤「底層安全系統無法找到您的數字身份證名稱」。移動郵件的VBA腳本無法處理加密郵件
如何調整我的代碼以便移動加密的消息?
Public Sub MoveToArchive()
Dim objOutlook As Outlook.Application
Dim objSourceNamespace As Outlook.NameSpace
Dim objDestNamespace As Outlook.NameSpace
Dim objSourceFolder As Outlook.MAPIFolder
Dim objDestFolder As Outlook.MAPIFolder
Dim objVariant As Variant
Dim lngMovedMailItems As Long
Dim intCount As Integer
Dim strDestFolder As String
' Create an object for the Outlook application.
Set objOutlook = Application
' Retrieve an object for the MAPI namespace.
Set objSourceNamespace = objOutlook.GetNamespace("MAPI")
Set objDestNamespace = objOutlook.GetNamespace("MAPI")
' Retrieve a folder object for the source folder.
Set objSourceFolder = objSourceNamespace.Folders("Mailbox - Me").Folders("Deleted Items")
Set objDestFolder = objDestNamespace.Folders("Archive - Current Year").Folders("Deleted Items")
' Loop through the items in the folder. NOTE: This has to
' be done backwards; if you process forwards you have to
' re-run the macro an inverese exponential number of times.
For intCount = objSourceFolder.Items.Count To 1 Step -1
' Retrieve an object from the folder.
'Debug.Print objSourceFolder.Items.Item(intCount)
Set objVariant = objSourceFolder.Items.Item(intCount)
' Allow the system to process. (Helps you to cancel the
' macro, or continue to use Outlook in the background.)
DoEvents
' Filter objects for emails or meeting requests.
If objVariant.Class = olMail Or objVariant.Class = olMeetingRequest Then
' This is optional, but it helps me to see in the
' debug window where the macro is currently at.
' Debug.Print objVariant.SentOn
' Move the object to the destination folder.
objVariant.Move objDestFolder
' Just for curiousity, I like to see the number
' of items that were moved when the macro completes.
lngMovedMailItems = lngMovedMailItems + 1
End If
Next
' Display the number of items that were moved.
' MsgBox "Moved " & lngMovedMailItems & " messages(s)."
End Sub
我有我自己的宏自簽名,但對我來說它出現以下錯誤:'運行時錯誤'-2147217663(80040f01)':此數字簽名的電子郵件有一個收據請求,所以不能打開在一個無UI的模式 – user1537366