2010-01-13 7 views

답변

12

확인이 link를 사용하려면 특히 C#을에서 폴더에 액세스하는 방법에 대한 기술 자료 문서, Programming samples that can reference items and folders in Outlook by using Visual C# .NET

가있다. Introduction to Outlook Programming은 더 명확하게 사물을 설명합니다.

메일 항목을 반복 할 수 있습니다. 샘플 코드

using System.Runtime.InteropServices; 
using OutLook = Microsoft.Office.Interop.Outlook; 
using Office = Microsoft.Office.Core; 

    OutLook.Application oApp; 
      OutLook._NameSpace oNS; 
      OutLook.MAPIFolder oFolder; 
      OutLook._Explorer oExp; 

      oApp = new OutLook.Application(); 
      oNS = (OutLook._NameSpace)oApp.GetNamespace("MAPI"); 
      oFolder = oNS.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderInbox); 
      oExp = oFolder.GetExplorer(false); 
      oNS.Logon(Missing.Value, Missing.Value, false, true); 

     OutLook.Items items = oFolder.Items; 
     foreach (OutLook.MailItem mail in items) 
         { 

          if (mail.UnRead == true) 
          { 
         } 
     } 

편집 : 폴더에있는 모든 항목을 통해 반복은 Reference other folders

oFolder.Folders["Foldername"] 

OutLook Code

Common Outlook tasks

+0

그래 그게 내가 원하는 것! 감사합니다. 그러나 Outlook에있는 다른 사서함에서받은 편지함의 항목을 가져 오는 방법이 있습니까? – Phil

+0

폴더의 모든 항목을 반복하는 것은 끔찍한 생각입니다. 특히 온라인 Exchange 저장소에 대해 작업하는 경우 특히 그렇습니다. Items.Find/FindNext 또는 Items.Restrict는 이동 방법입니다. –

2

Outlook 폴더에 액세스하는 몇 가지 예가 here이며, 그 중 하나는 읽지 않은 메일을 처리합니다.

편집 : 다른 사용자의 폴더를 열 GetSharedDefaultFolder

+0

하지만 난 C#을 필요 :/ – Phil

2

당신이 온라인에 대해 작업하는 경우 특히, 끔찍한 생각이다 Exchange 저장소. Items.Find/FindNext 또는 Items.Restrict는 이동 방법입니다.

찾기/FindNext :

OutLook.Items items = oFolder.Items; 
OutLook.MailItem mail = items.Find("[Unread] = true"); 
while (mail != null) 
{ 
    MessageBox.Show(mail.Subject); 
    mail = items.FindNext(); 
} 

Items.Restrict :

OutLook.Items items = oFolder.Items.Restict("[Unread] = true") 
foreach (OutLook.MailItem mail in items) 
{ 
    MessageBox.Show(mail.Subject); 
} 
+0

어제의 이메일을 검색하는 필터 란 무엇입니까? 나는 이것을 시도했다 [SentOn]> '5/17/2017 4:21:33 PM'하지만 작동하지 않는 것 같습니다. 제로 레코드를 반환합니다 –

+0

또는 [ReceivedTime]입니다. –

+0

예 날짜 형식을 잘못 지정했습니다. 감사 –

관련 문제