2011-11-01 5 views
1

メッセージを個人用フォルダにアーカイブするために使用するVBAスクリプトがあります。通常のメッセージではうまく動作しますが、暗号化されたメッセージに遭遇するたびに、「あなたのデジタルID名は、基礎となるセキュリティシステムでは見つかりません」というランタイムエラーが発生します。メッセージを移動する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 

答えて

1

暗号化された電子メールではVBAコードから何もできません。 VBAからは、実際に暗号化されているとは言えません。私はS/MIMMEタイプのアタッチメントがあると言う人もいます。あなたはあなたの電子メールでそれを確認することができます。私は会社の暗号化でそれを見つけられませんでした。

また、VBAで暗号化された電子メールを移動することもできません。

私の意見では、objVariantを使って簡単なプロパティを読み取ろうとしています。あなたができない場合、あなたはエラーを取得し、それが暗号化されていると仮定します。

0

これはOutlook 2007でツールバーにGmailスタイルの「アーカイブ」ボタンを実装するために使用するコードです。

Sub Archive() 
    Set ArchiveFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders("Archive") 
    For Each Msg In ActiveExplorer.Selection 
     If ActiveExplorer.Selection.Parent <> ArchiveFolder Then Msg.Move ArchiveFolder 
    Next Msg 
End Sub 

動作するには自己署名する必要があります。 http://www.howto-outlook.com/howto/selfcert.htm

暗号化されたファイルを移動しようとすると、ファイルは操作後に署名されなくなり、[OK]をクリックした後でも操作を正常に完了したという警告が表示されます。

+0

私は自己署名したマクロを持っていますが、私にとっては次のエラーが出ます: '実行時エラー '-2147217663(80040f01)':このデジタル署名された電子メールには領収書要求があり、 UIレスモード。 – user1537366

関連する問題