Outlook 메시지 (MSG) 파일 읽기
Contents
[
Hide
]
우리의 마이그레이션 팁은 Aspose 제품을 사용하여 애플리케이션을 개선하고 기존 자동화에 대한 의존성을 없앨 수 있는 방법을 보여줍니다.
이 마이그레이션 팁은 Microsoft Outlook 메시지 파일을 읽고 화면에 내용을 표시하는 방법을 두 가지 모두 사용하여 보여줍니다. Microsoft Office 자동화 및 Aspose.Email 코드. 아래 샘플 코드는 작동 방식을 이해할 수 있도록 콘솔에 내용만 표시합니다. 해당 코드 스니펫을 자신의 Windows, 웹 또는 기타 애플리케이션에서 사용하십시오.
Office 자동화
Microsoft Outlook용 Office Automation 객체를 사용하려면 프로젝트에 Microsoft Office 및 Microsoft Office Interop for Outlook 라이브러리 참조를 추가해야 합니다.
프로그래밍 샘플
C#
// Add the namespaces
using Microsoft.Office;
using Microsoft.Office.Interop.Outlook;
// Create a new Application Class
Application app = new Application();
// Create a MailItem object
MailItem item = (MailItem)outlook.CreateItemFromTemplate(@"d:\temp\test.msg", Type.Missing);
// Access different fields of the message
System.Console.WriteLine(string.Format("Subject:{0}", item.Subject));
System.Console.WriteLine(string.Format("Sender Email Address:{0}", item.SenderEmailAddress));
System.Console.WriteLine(string.Format("SenderName:{0}", item.SenderName));
System.Console.WriteLine(string.Format("TO:{0}", item.To));
System.Console.WriteLine(string.Format("CC:{0}", item.CC));
System.Console.WriteLine(string.Format("BCC:{0}", item.BCC));
System.Console.WriteLine(string.Format("Html Body:{0}", item.HTMLBody));
System.Console.WriteLine(string.Format("Text Body:{0}", item.Body));
Aspose.Email for Java
다음 코드 스니펫은 다음과 동일한 작업을 수행합니다. 위의 코드 Aspose.Email for Java를 사용합니다.
에 접근하려면 Aspose.Email Outlook 객체를 사용하려면 프로젝트에 Aspose.Email에 대한 참조를 추가해야 합니다.
프로그래밍 샘플
// Create a new object of type MapiMessage
MapiMessage msg = MapiMessage.fromFile("d:\\temp\\test.msg");
// Access the fields of the message
System.out.println("Subject: " + msg.getSubject());
System.out.println("Sender Email Address: " + msg.getSenderEmailAddress());
System.out.println("SenderName:{0}" + msg.getSenderName());
System.out.println("TO:{0}" + msg.getDisplayTo());
System.out.println("CC:{0}" + msg.getDisplayCc());
System.out.println("BCC:{0}" + msg.getDisplayBcc());
System.out.println("Html Body:{0}" + msg.getBodyHtml());
System.out.println("Text Body:{0}" + msg.getBody());
System.out.println("Rtf Body:{0}" + msg.getBodyRtf());