규칙에 따라 모든 메일이 보관되는 폴더를 만들었습니다. 폴더의 메일은 매일 누적됩니다. 해당 폴더의 최신 메일에서 첨부 파일을 다운로드하고 싶습니다. 현재 모든 파일을 구문 분석하고 모든 메일에서 첨부 파일을 다운로드 할 수 있습니다. 최신 메일에서만 다운로드하려면 어떻게합니까? 아래는 내 코드입니다.
Sub FebAttachment_Click()
Const AttachmentPath As String = "D:\Documents and Settings\rahul.baskaran\Desktop\"
Dim oApp As Object, ONS As Object, OInb As Object
Dim OItem, OAtch As Object
Dim OFind As Object
Dim OMail As Object
Dim strName As String
Dim strExt As String
Set oApp = GetObject(, "Outlook.application")
Set ONS = oApp.GetNamespace("MAPI")
Set OInb = ONS.Folders("Archive Folders").Folders("BIZOPS").Folders("2014.02")
Set OMail = OInb.Items
For Each OItem In OInb.Items
If OItem.Attachments.Count <> 0 Then
For Each OAtch In OItem.Attachments
strName = OAtch.Filename
strExt = Split(strName, ".z")(0)
OAtch.SaveAsFile AttachmentPath & OAtch.Filename
Exit For
Next
Else
MsgBox "The mail doesn't have an attachment"
End If
Next OItem
생성 날짜 (Items.Sort)를 기준으로 항목을 내림차순으로 정렬 한 다음 컬렉션의 첫 번째 항목을 검색합니다.
코드가 동일한 Items 컬렉션에서 작동하는지 확인합니다 (OInb.Items를 한 번 검색하고 변수에 캐시).
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다