Outlook 템플릿 파일 OFT 읽기

Aspose.Email - Outlook 템플릿 OFT 읽기

Aspose.Email의 MailMessage 클래스를 사용하면 Microsoft Outlook 템플릿(OFT) 파일을 로드할 수 있습니다. Outlook 템플릿이 MailMessage 클래스 인스턴스에 로드되면 발신자, 수신자, 본문, 제목 및 기타 속성을 업데이트할 수 있습니다.

Java


 // Load the Outlook template (OFT) file in MailMessage's instance

MailMessage message = MailMessage.load(dataDir + "sample.oft");

// Set the sender and recipients information

String senderDisplayName = "John";

String senderEmailAddress = "john@abc.com";

String recipientDisplayName = "William";

String recipientEmailAddress = "william@xzy.com";

message.setSender(new MailAddress(senderEmailAddress, senderDisplayName));

message.getTo().addMailAddress(new MailAddress(recipientEmailAddress, recipientDisplayName));

message.setHtmlBody(message.getHtmlBody().replace("DisplayName", "<b>" + recipientDisplayName + "</b>"));

// Set the name, location and time in email body

String meetingLocation = "<u>" + "Hall 1, Convention Center, New York, USA" + "</u>";

String meetingTime = "<u>" + "Monday, June 28, 2010" + "</u>";

message.setHtmlBody(message.getHtmlBody().replace("MeetingPlace", meetingLocation));

message.setHtmlBody(message.getHtmlBody().replace("MeetingTime", meetingTime));

// Save the message in MSG format and open in Office Outlook

MapiMessage mapimessage = new MapiMessage().fromMailMessage(message);

mapimessage.setMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT);

mapimessage.save(dataDir + "AsposeInvitation.msg");

실행 코드 다운로드

샘플 코드 다운로드