We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Appointment Attachment with URI attachment

I have an icalendar file which has three attachments, 2 of which are referenced by URI. I’d like to get the URI from an instance of Attachment but I don’t see a way to do that from the documentation. Using Aspose Email 21.2 for Java with the CalendarReader API.

val loadOptions = AppointmentLoadOptions().apply {
      applyLocalTZ = false
      detectEncoding = true
      ignoreSmtpAddressCheck = true

val reader = CalendarReader(PATH, loadOptions)
while (reader.nextEvent()) {
  val appointment = reader.getCurrent()

   for (attachment in appointment.attachments) {
    if (attachment.isUri()) {
        println("Name: ${attachment.name}")
        attachment.contentDisposition?.let { contentDisposition ->
            println("Content-Disposition filename: ${contentDisposition.getFileName()}")
            println("Content-Disposition type: ${contentDisposition.getDispositionType()}")

The filename is “Unnamed”. There is nothing in the Appointment or Attachment API which I can see to get the URI of the attachment.
sample-event-with-attachment.ics.zip (6.9 KB)

Thank you for your request. You can get the URI from an Attachment instance as below:

if (attachment.isUri())
    InputStream inputStream = attachment.getContentStream();
    String uri = new String(IOUtils.toByteArray(inputStream), Charset.forName("utf-8"));

API Reference: AttachmentBase class

Confirmed this is working as expected. Thank you.