Package com.independentsoft.graph

# Class Attachment

java.lang.Object
com.independentsoft.graph.Attachment

All Implemented Interfaces:
  `ICreatable`

Direct Known Subclasses:
  `FileAttachment`, `ItemAttachment`, `ReferenceAttachment`

public abstract class Attachment extends Object implements ICreatable
Abstract base class for attachments in Microsoft Graph.

Attachments can be added to messages, events, and other items. Microsoft Graph supports three types of attachments:

- FileAttachment - A file (such as a document, image, or PDF) attached to a message or event
- ItemAttachment - An Outlook item (message, event, contact) attached to another item
- ReferenceAttachment - A link to a file on OneDrive or other cloud storage

Attachments have size limits:

- File attachments: Up to 150 MB per attachment
- Total attachments per message: Up to 150 MB combined

Example usage:

     // Add a file attachment to a message
     FileAttachment attachment = new FileAttachment();
     attachment.setName("report.pdf");
     attachment.setContentType("application/pdf");
     attachment.setContentBytes(fileBytes);

     Message message = new Message();
     message.setSubject("Monthly Report");
     message.getAttachments().add(attachment);

     client.createMessage(message);

Since:
  1.0
See Also:
  attachment resource type, fileAttachment resource type, itemAttachment resource type

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected String`
  `contentType`
  `protected String`
  `id`
  `protected boolean`
  `isInline`
  `protected Date`
  `lastModifiedTime`
  `protected String`
  `name`
  `protected int`
  `size`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Attachment()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getContentType()`
  Gets the MIME type of the attachment.
  `String`
  `getId()`
  Gets the unique identifier of the attachment.
  `Date`
  `getLastModifiedTime()`
  Gets the last modified date/time of the attachment.
  `String`
  `getName()`
  Gets the name of the attachment.
  `int`
  `getSize()`
  Gets the size of the attachment in bytes.
  `boolean`
  `isInline()`
  Checks if the attachment is inline (embedded in message body).
  `void`
  `setContentType​(String contentType)`
  Sets the MIME type of the attachment.
  `void`
  `setInline​(boolean inline)`
  Sets whether the attachment is inline.
  `void`
  `setName​(String name)`
  Sets the name of the attachment.
  `abstract String`
  `toCreateJson()`
  Generates JSON representation for creating this attachment.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### id

    protected String id

  - ### contentType

    protected String contentType

  - ### isInline

    protected boolean isInline

  - ### lastModifiedTime

    protected Date lastModifiedTime

  - ### name

    protected String name

  - ### size

    protected int size

- ## Constructor Details

  - ### Attachment

    public Attachment()

- ## Method Details

  - ### toCreateJson

    public abstract String toCreateJson()
    Generates JSON representation for creating this attachment.
    Specified by:
      `toCreateJson` in interface `ICreatable`
    Returns:
      JSON string for creation

  - ### getId

    public String getId()
    Gets the unique identifier of the attachment.
    Returns:
      The attachment ID

  - ### getContentType

    public String getContentType()
    Gets the MIME type of the attachment.
    Returns:
      The content type (e.g., "application/pdf", "image/jpeg")

  - ### setContentType

    public void setContentType​(String contentType)
    Sets the MIME type of the attachment.
    Parameters:
      `contentType` - The content type

  - ### isInline

    public boolean isInline()
    Checks if the attachment is inline (embedded in message body).
    Returns:
      true if the attachment is inline, false otherwise

  - ### setInline

    public void setInline​(boolean inline)
    Sets whether the attachment is inline.
    Parameters:
      `inline` - true for inline attachment, false for regular attachment

  - ### getLastModifiedTime

    public Date getLastModifiedTime()
    Gets the last modified date/time of the attachment.
    Returns:
      The last modified timestamp

  - ### getName

    public String getName()
    Gets the name of the attachment.
    Returns:
      The file name or attachment name

  - ### setName

    public void setName​(String name)
    Sets the name of the attachment.
    Parameters:
      `name` - The file name or attachment name

  - ### getSize

    public int getSize()
    Gets the size of the attachment in bytes.
    Returns:
      The size in bytes