ICS를 다른 형식으로 변환

ICS를 EML로 변환

캘린더 이벤트 또는 일정 표현을 위해 Aspose.Email은 다음을 제공합니다 Appointment 클래스. 다음 코드 예제는 ICS를 EML로 변환하는 과정을 보여줍니다:

  1. 다음 방법을 사용하여 변환할 ICS 파일을 로드합니다 Appointment.load 메서드.
  2. 새로운 MailMessage 캘린더 데이터를 보관하는 객체.
  3. ICS 파일의 일정을 대체 뷰로 EML에 추가하려면 다음을 사용합니다 requestApointment() 메서드.
  4. 변환된 데이터를 사용하여 EML 파일을 저장하려면 다음을 사용합니다 저장 메서드와 함께 EmlSaveOptions 저장 유형을 지정합니다 EmlFormat.
// Load the ICS file to be converted
Appointment ics = Appointment.load("My File.ics");
// Create an EML
MailMessage eml = new MailMessage();
// Add the appointment to the EML
eml.addAlternateView(ics.requestApointment());
// Save the EML
eml.save("Saved File.eml", new EmlSaveOptions(MailMessageSaveType.getEmlFormat()));

ICS를 EMLX로 변환

ICS 파일을 EMLX 형식으로 변환하려면 아래 지침을 따르세요: ICS를 EML로 변환 섹션을 저장하고 .emlx 파일을 다음 코드 줄과 같이 저장합니다:

Appointment ics = Appointment.load("My File.ics");
MailMessage eml = new MailMessage();
eml.addAlternateView(ics.requestApointment());

// Save as an EMLX
eml.save("Saved File.emlx", new EmlSaveOptions(MailMessageSaveType.getEmlxFormat()));

ICS를 HTML로 변환

다음 코드 샘플은 변환 과정을 보여줍니다:

  1. 다음 방법을 사용하여 변환할 ICS 파일을 로드합니다 Appointment.load 메서드.
  2. 새로운 MailMessage 캘린더 데이터를 보관하는 객체.
  3. ICS 파일의 일정을 대체 뷰로 EML에 추가하려면 다음을 사용합니다 requestApointment() 메서드.
  4. 변환된 데이터를 사용하여 EML 파일을 저장하려면 다음을 사용합니다 저장 메서드와 함께 HtmlSaveOptions 저장된 HTML 파일에 대한 서식 옵션을 제공하기 위해 사용합니다. 이 경우에는 HtmlFormatOptions.WriteHeader 출력 파일에 HTML 헤더를 포함하는 데 사용되며, HtmlFormatOptions.RenderCalendarEvent EML 메시지에 포함된 캘린더 이벤트를 표시하기 적합한 형식으로 렌더링하는 데 사용됩니다.
// Load the ICS file to be converted
Appointment ics = Appointment.load("My File.ics");
// Create an EML
MailMessage eml = new MailMessage();
// Add the appointment to the EML
eml.addAlternateView(ics.requestApointment());

// Save the EML as HTML
HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions();
htmlSaveOptions.setHtmlFormatOptions(HtmlFormatOptions.WriteHeader | HtmlFormatOptions.RenderCalendarEvent);
eml.save("Saved File.html", htmlSaveOptions);

다른 값을 사용하세요 HtmlFormatOptions 열거형 및 속성 HtmlSaveOptions 필요에 따라 형식 옵션을 설정하는 클래스.

ICS를 MBOX로 변환

다음 코드 예제는 ICS를 MBOX로 변환하는 과정을 보여줍니다. 이 과정에서는 ICS 파일을 로드하고, EML 메시지를 생성한 뒤, 그 안에 ICS 파일의 일정 세부 정보를 추가하고, 마지막으로 EML 메시지를 MBOX 저장 파일에 기록합니다.

  1. 다음 방법을 사용하여 변환할 ICS 파일을 로드합니다 Appointment.load 메서드.
  2. 새로운 MailMessage 캘린더 데이터를 보관하는 객체.
  3. ICS 파일의 일정을 대체 뷰로 EML에 추가하려면 다음을 사용합니다 requestApointment() 메서드.
  4. 새로운 MboxrdStorageWriter 객체.
  5. MBOX 형식으로 메시지 내용을 지정된 MBOX 파일에 기록하여 EML 메시지를 스토리지에 추가합니다.
// Load the ICS file to be converted
Appointment ics = Appointment.load("My File.ics");
// Create an EML
MailMessage eml = new MailMessage();
// Add the appointment to the EML
eml.addAlternateView(ics.requestApointment());

// Create an MBOX storage and add the EML to it
try (MboxrdStorageWriter mboxStorage = new MboxrdStorageWriter("Saved File.mbox", new MboxSaveOptions())) {
    mboxStorage.writeMessage(eml);
}

ICS를 MHTML로 변환

다음 코드 예제는 변환 과정의 모든 단계를 보여줍니다:

  1. 다음 방법을 사용하여 변환할 ICS 파일을 로드합니다 Appointment.load 메서드.
  2. 새로운 MailMessage 변환된 데이터를 보관하는 객체.
  3. ICS 파일의 일정을 대체 뷰로 EML에 추가하려면 다음을 사용합니다 requestApointment() 메서드.
  4. 변환된 데이터를 사용하여 EML 파일을 저장하려면 다음을 사용합니다 저장 메서드와 함께 MhtSaveOptions MHTML 파일 저장 옵션을 제공하기 위해 사용합니다. 이 경우에는 MhtFormatOptions.WriteHeader 출력 파일에 이메일 메시지 헤더를 포함하는 데 사용되며, MhtFormatOptions.RenderCalendarEvent EML 메시지에 포함된 캘린더 이벤트를 표시하기 적합한 형식으로 렌더링하는 데 사용됩니다.
// Load the ICS file to be converted
Appointment ics = Appointment.load("My File.ics");
// Create an EML
MailMessage eml = new MailMessage();
// Add the appointment to the EML
eml.addAlternateView(ics.requestApointment());

// Save the EML as MHTML
MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();
mhtSaveOptions.setMhtFormatOptions(MhtFormatOptions.WriteHeader | MhtFormatOptions.RenderCalendarEvent);
eml.save("Saved File.mht", mhtSaveOptions);

이 접근 방식은 변환된 MHTML 파일이 캘린더 이벤트 세부 정보와 형식을 유지하도록 보장하여 다양한 플랫폼 및 이메일 클라이언트에서 효율적인 공유와 조회가 가능하도록 합니다.

다른 값을 자유롭게 사용하세요 MhtFormatOptions 열거형 및 속성 MhtSaveOptions 필요에 따라 형식 옵션을 설정하는 클래스.

ICS를 MSG로 변환

ICS(iCalendar) 파일을 MSG 형식으로 변환하면 Microsoft Outlook과의 호환성이 향상됩니다. MSG 파일은 이메일, 약속 및 기타 Outlook 데이터 저장에 일반적으로 사용됩니다. 다음 코드 예제는 데이터 손실이나 서식 손실 없이 ICS 파일을 로드하고 MSG 파일로 저장하는 방법을 보여줍니다:

  1. ICS 파일을 로드합니다 Appointment.load 그리고 생성합니다 Appointment 파일에 저장된 캘린더 데이터에서 가져온 객체.
  2. 다음을 호출합니다. save Appointment 객체의 메서드를 사용하여 로드된 예약 데이터를 지정된 위치에 MSG 파일로 변환 및 저장합니다.
// Load the ICS file to be converted and save it as an MSG
Appointment.load("My File.ics").save("Saved File.msg", AppointmentSaveFormat.Msg);

ICS를 OFT로 변환

이 프로세스는 ICS 파일을 로드하고 MSG 파일로 저장한 뒤 OFT 형식으로 추가 변환하는 과정을 포함합니다:

  1. 메모리 내에 예약 데이터를 저장할 새 스트림 객체를 생성합니다.
  2. ICS 파일에서 약속 데이터를 로드합니다. 약속 데이터를 MSG 형식으로 스트림 객체에 저장하려면 save() 메서드.
  3. 스트림에서 예약 데이터를 로드하려면 다음을 사용하여 새 MapiMessage 객체를 생성합니다 MapiMessage.load() 메서드.
  4. 로드된 MapiMessage 데이터를 Outlook 템플릿 파일로 저장하려면 다음을 사용합니다 save() 메서드와 함께 SaveOptions.getDefaultOft() 포맷 옵션.
// Load the ICS file to be converted and save it as an MSG into a stream
ByteArrayOutputStream msgStream = new ByteArrayOutputStream();
Appointment.load("My File.ics").save(msgStream, AppointmentSaveFormat.Msg);

// Save the MSG as an OFT
MapiMessage.load(new ByteArrayInputStream(msgStream.toByteArray()))
        .save("Saved File.oft", SaveOptions.getDefaultOft());

ICS를 OST로 변환

Aspose.Email은 ICS 파일을 로드하고 MSG 파일로 저장한 뒤 OST 파일을 열어 파일 내 캘린더 폴더에 접근하고 MSG 파일을 캘린더 폴더에 쉽게 추가하는 기능을 제공합니다:

  1. 예약 데이터를 저장할 스트림을 생성합니다.
  2. 다음 방법을 사용하여 ICS 파일에서 약속 데이터를 로드합니다. Appointment.load() 메서드를 사용하여 스트림에 MSG 형식으로 저장합니다. save 메서드.
  3. 개인 저장소 파일을 로드합니다 fromFile 메서드 PersonalStorage 클래스. 전달합니다 true 두 번째 인수로 스토리지를 쓰기 모드로 엽니다.
  4. 개인 저장소 파일에서 캘린더 폴더를 검색합니다 getPredefinedFolder 메서드.
  5. 다음 사용 addMessage 메서드 - OST 파일의 캘린더 폴더에 약속 메시지를 추가합니다.
// Load the ICS file to be converted and save it as an MSG into a stream
ByteArrayOutputStream msgStream = new ByteArrayOutputStream();
Appointment.load("My File.ics").save(msgStream, AppointmentSaveFormat.Msg);

// Open an OST file
try (PersonalStorage pst = PersonalStorage.fromFile("Saved File.ost", true)) {
    // Get the calendar folder
    FolderInfo calendarFolder = pst.getPredefinedFolder(StandardIpmFolder.Appointments);
    // Add the MSG to the calendar folder
    calendarFolder.addMessage(MapiMessage.load(new ByteArrayInputStream(msgStream.toByteArray())));
}

ICS를 PST로 변환

다음 코드 샘플은 변환 과정을 보여줍니다:

  1. 약속 데이터를 담을 스트림을 생성합니다.
  2. 다음 방법을 사용하여 ICS 파일에서 약속 데이터를 로드합니다. Appointment.load() 메서드를 사용하여 스트림에 MSG 형식으로 저장합니다. save 메서드.
  3. 다음 방법을 사용하여 지정된 파일 이름으로 새 PST 파일을 생성합니다. PersonalStorage.create 메서드.
  4. 다음 방법을 사용하여 PST 파일 내에 약속을 저장할 캘린더 폴더를 생성합니다. createPredefinedFolder 메서드.
  5. 다음 방법을 사용하여 PST 파일 내 캘린더 폴더에 약속 메시지를 추가합니다. addMessage 메서드.
// Load the ICS file to be converted and save it as an MSG into a stream
ByteArrayOutputStream msgStream = new ByteArrayOutputStream();
Appointment.load("My File.ics").save(msgStream, AppointmentSaveFormat.Msg);

// Create a PST file
try (PersonalStorage pst = PersonalStorage.create("Saved File.pst", FileFormatVersion.Unicode)) {
    // Create a calendar folder
    FolderInfo calendarFolder = pst.createPredefinedFolder("Calendar", StandardIpmFolder.Appointments);
    // Add the MSG to the calendar folder
    calendarFolder.addMessage(MapiMessage.load(new ByteArrayInputStream(msgStream.toByteArray())));
}