我正在尝试建立一个宏,以删除散布在MS Outlook联系人注释字段中的一系列电子邮件。到目前为止,这就是我所拥有的,当它执行时,似乎什么都看不见。感谢任何反馈。电子邮件看起来像<[email protected]>
Sub OutlookDeleteTextBetween()
Dim olInspector As Outlook.Inspector
Dim olDocument As Word.Document
Dim olSelection As Word.Selection
Set olInspector = Application.ActiveInspector()
Set olDocument = olInspector.WordEditor
Set olSelection = olDocument.Application.Selection
olSelection.WholeStory
With olSelection.Find
.Text = "\<*\>"
.MatchWildcards = True
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
End Sub
删除一系列散布在MS Outlook联系人注释字段中的电子邮件
进行一些更改后,尝试Save
邮件项目。在您保存项目或重新打开窗口之前,Outlook可能不会传播更改。
如果需要查找附件邮件项目,它们将作为附件存储在Outlook项目中。在您看来,您需要检出Attachments
集合并使用Attachments.Remove方法从集合中删除一个对象。例如:
Sub RemoveAttachmentBeforeForwarding()
Dim myinspector As Outlook.Inspector
Dim myItem As Outlook.MailItem
Dim myattachments As Outlook.Attachments
Set myinspector = Application.ActiveInspector
If Not TypeName(myinspector) = "Nothing" Then
Set myItem = myinspector.CurrentItem.Forward
Set myattachments = myItem.Attachments
While myattachments.Count > 0
myattachments.Remove 1
Wend
myItem.Display
myItem.Recipients.Add "Eugene Astafiev"
myItem.Send
Else
MsgBox "There is no active inspector."
End If
End Sub