
우리는 이메일을 통해 업데이트를 보내는 자동화된 시스템을 갖추고 있습니다. 괜찮습니다. 저에게는 유용한 정보입니다. 가장 최근 업데이트만 보고 나머지는 휴지통으로 두고 싶습니다. 즉, 다음 목록이 주어지면
선택한 버전의 34022 업데이트만 내 폴더에 남아 있기를 원합니다. 규칙을 찾아보았지만 해당 사항에 맞는 것이 없는 것 같습니다.
원하지 않는 항목을 (자동으로) 삭제하는 방법이 있나요?
답변1
일부 VBA를 사용합니다. 삭제와 관련된 경우 항상 철저하게 테스트하는 것이 좋습니다.
Private Sub Application_NewMail()
' In ThisOutlookSession module
' see Create Outlook Rules Programmatically
' http://msdn.microsoft.com/en-us/library/aa163981(v=office.10).aspx
Dim olApp As Outlook.Application
Dim olNs As Outlook.NameSpace
Dim olFld As Outlook.MAPIFolder
Dim objMail As Object
Set olApp = Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set olFld = olNs.GetDefaultFolder(olFolderInbox)
olFld.items.sort "Received", False
'Set objMail = olFld.items.GetFirst ' In Outlook 2003
Set objMail = olFld.items.GetLast ' In Outlook 2010
If TypeOf objMail Is MailItem Then
If objMail.SenderEmailAddress = "Found in DetermineSenderEmailAddress" And _
InStr(1, objMail.Subject, "Ticket:") Then
DeleteOldStatus objMail
End If
End If
Set objMail = Nothing
Set olFld = Nothing
Set olNs = Nothing
Set olApp = Nothing
End Sub
Sub DeleteOldStatus(objMail As MailItem)
Dim olFld As folder
Dim olNs As NameSpace
Dim olderMail As MailItem
Dim iDel As Long
Set olNs = Application.GetNamespace("MAPI")
Set olFld = olNs.GetDefaultFolder(olFolderInbox)
For iDel = olFld.items.Count To 1 Step -1
Set olderMail = olFld.items(iDel)
If olderMail.Subject = objMail.Subject Then
If olderMail.ReceivedTime < objMail.ReceivedTime Then
Debug.Print olderMail.Subject & " received " & olderMail.ReceivedTime & " should be deleted."
'olderMail.Delete ' Remove leading apostrophe to uncomment when ready
End If
End If
Next
Debug.Print "Done - " & objMail.Subject
End Sub
Sub DetermineSenderEmailAddress()
' open up an email then run
Dim currItem As MailItem
Set currItem = ActiveInspector.currentItem
' Copy the text from the immediate pane.
Debug.Print currItem.SenderEmailAddress
End Sub
편집기 및 버튼 도움말 -http://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/
매크로 보안은 중간으로 설정해야 합니다.
버튼 도움말 -http://www.howto-outlook.com/howto/macrobutton.htm
편집: InStr 라인 수정