Log in

View Full Version : [SLEEPER:] Code to move encrypted emails



anthonyleg
05-06-2024, 08:28 PM
Hello guys,
I want to move encrypted emails. But I find that the "object. move" function does not work on ecrypted emails. All suggestion about the right code?

Aussiebear
05-06-2024, 09:24 PM
Welcome to VBAX. This issue comes up regularly. What code have you been trying?

gregbowers
06-02-2024, 02:07 AM
To move encrypted emails, use the Copy and Delete methods instead of Move. Here’s a quick code example:


Sub MoveEncryptedEmails()
Dim sourceFolder As Outlook.MAPIFolder
Dim targetFolder As Outlook.MAPIFolder
Dim item As Object
Set sourceFolder = Application.Session.GetDefaultFolder(olFolderInbox)
Set targetFolder = Application.Session.Folders("YourTargetFolder")
For Each item In sourceFolder.Items
If item.Class = olMail And item.PropertyAccessor.GetProperty("http://schemas.microsoft.com/ _
mapi/proptag/0x7D01001E") = "IPM.Note.SMIME.MultipartSigned" Then
item.Copy targetFolder
item.Delete
End If
Next
End Sub

Replace "YourTargetFolder" with your actual target folder name.

Aussiebear
06-02-2024, 03:54 AM
I have no experience with Outlook vba, so if I ever saw this string ("http://schemas.microsoft.com/ _
mapi/proptag/0x7D01001E") = "IPM.Note.SMIME.MultipartSigned") used somewhere, does it indicate the email is definitely encrypted?