使用VBA永久删除Outlook中的MailMessage吗? [英] Permanently Delete MailMessage in Outlook with VBA?
问题描述
我正在寻找一种使用VBA代码从Outlook 2000中永久删除MailMessage的方法.我想执行此操作,而无需执行第二个循环来清空已删除"项目.
I am looking for a way to permanently delete a MailMessage from Outlook 2000 with VBA code. I'd like to do this without having to do a second loop to empty the Deleted items.
本质上,我正在寻找与单击消息并单击 SHIFT + DELETE 的UI方法等效的代码.
Essentially, I am looking for a code equivalent to the UI method of clicking a message and hitting SHIFT+DELETE.
有这样的东西吗?
推荐答案
尝试先移动它,然后将其删除(在2000年的某些补丁程序中可用),或者使用RDO或CDO为您完成此工作(您必须安装它们)
Try moving it first then deleting it (works on some patchs in 2000) or use RDO or CDO to do the job for you (you will have to install them)
Set objDeletedItem = objDeletedItem.Move(DeletedFolder)
objDeletedItem.Delete
CDO方式
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon "", "", False, False
Set objMail = objCDOSession.GetMessage(objItem.EntryID, objItem.Parent.StoreID)
objMail.Delete
set objRDOSession = CreateObject("Redemption.RDOSession")
objRDOSession.MAPIOBJECT = objItem.Session.MAPIOBJECT
set objMail = objRDOSession.GetMessageFromID(objItem.EntryID>)
objMail.Delete
您还可以先标记该消息,然后再将其删除,然后循环遍历已删除邮件"文件夹,然后再次找到该呼叫并删除它.使用用户属性对其进行标记.
You could also mark the message first before you delete it and the loop through the deleted items folder and find it an dthe call delete a second time. Mark it using a Userproperty.
objMail.UserProperties.Add "Deleted", olText
objMail.Save
objMail.Delete
在删除的项目中循环查找该用户属性
loop through you deleted items look for that userprop
Set objDeletedFolder = myNameSpace.GetDefaultFolder(olFolderDeletedItems)
For Each objItem In objDeletedFolder.Items
Set objProperty = objItem.UserProperties.Find("Deleted")
If TypeName(objProperty) <> "Nothing" Then
objItem.Delete
End If
Next
这篇关于使用VBA永久删除Outlook中的MailMessage吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!