2014-09-18 2 views
0

나는이 대부분을 이미 해결했지만 도움이 필요합니다. 다양한 Outlook 폴더의 이메일 수신 시간을 모두 저장하고 싶습니다. 모든 폴더는 같은 폴더 안에 있으므로 배열을 하나씩 가지고 있습니다. 변수를 저장하거나 write.console에 표시 할 수있는 시간이 필요합니다. 표시 할 시간은 수 백 가지가 될 것입니다. 변수는 Totalmsg이며이 시간을 저장 한 다음 완료되면 표시합니다. 대신,Outlook 사서함에있는 모든 전자 메일에서받은 시간을 가져 오는 방법

If Not objFolder Is Nothing Then 
    For Each MailItem In objFolder.Items 
     Totalmsg = MailItem.ReceivedTime 
    Next 
End If 

당신은 그것을에 추가하기를 원할 것입니다 :

Sub EmailArrivalTimes() 
Dim objOutlook As Object, objnSpace As Object, objFolder As MAPIFolder 
Dim MailItem 
Dim EmailCount() As Integer, arrNames 


Set objOutlook = CreateObject("Outlook.Application") 
Set objnSpace = objOutlook.GetNamespace("MAPI") 

arrNames = Array  ("Andrew", "Ashton", "Becca", "Beth", "Bree", "Brittany", "Cecilia", "Chance", "Christina J.", "Christine", "Dustin", "James", "Jeff", "Jenni", "Jennifer W.", "Josh", "Josie", "Kara", "Lisa", "Megan", "Misti", "Nathan", "Paul", "Sam", "Shane", "Shawna") 'add other names here... 
ReDim EmailCount(LBound(arrNames) To UBound(arrNames)) 

For x = LBound(arrNames) To UBound(arrNames) 

On Error Resume Next 
Set objFolder = objnSpace.Folders("Mailbox - IT Support Center"). _ 
     Folders("Onshore - " & arrNames(x)).Folders("completed") 
On Error GoTo 0 

ArrivalTime = 0 

Dim Totalmsg 

If Not objFolder Is Nothing Then 
    For Each MailItem In objFolder.Items 
     Totalmsg = MailItem.ReceivedTime 
Next 
End If 


Set OutMail = Nothing 
Set OutApp = Nothing 
Set objFolder = Nothing 
Set objnSpace = Nothing 
Set objOutlook = Nothing 

End Sub 
+0

문제 란 ? 오류가 있습니까? –

답변

0

은 지금이 루프의 각 반복에서 TotalMsg의 값을 덮어 쓰는

If Not objFolder Is Nothing Then 
    For Each MailItem In objFolder.Items 
     Totalmsg = TotalMsg & vbCRLF & MailItem.ReceivedTime 
    Next 
End If 

Debug.Print TotalMsg 
    'Note: this will likely exceed what can fit in the console window, _ 
    ' but you can instead write the string to a text file/etc. 
관련 문제