LinkedResource

Inheritance: java.lang.Object, com.aspose.email.AttachmentBase

public class LinkedResource extends AttachmentBase

Represents an embedded resource in a message.


The following example shows how to embed objects using LinkedResource into an Email.

[Java]

MailMessage eml = new MailMessage();
 eml.setFrom(MailAddress.to_MailAddress("AndrewIrwin@from.com"));
 eml.setTo(MailAddressCollection.to_MailAddressCollection("SusanMarc@to.com"));
 eml.setSubject("This is an email");

 // Create the plain text part It is viewable by those clients that don't support HTML
 AlternateView plainView = AlternateView.createAlternateViewFromString("This is my plain text content", null,
 "text/plain");

 // Create the HTML part.To embed images, we need to use the prefix 'cid' in the img src value.
 // The cid value will map to the Content-Id of a Linked resource. Thus <img src='cid:barcode'>
 // will map to a LinkedResource with a ContentId of 'barcode'.
 AlternateView htmlView = AlternateView.createAlternateViewFromString(
 "Here is an embedded image. <img src=cid:barcode>", null, "text/html");

 // Create the LinkedResource (embedded image) and Add the LinkedResource to the appropriate view
 LinkedResource barcode = new LinkedResource("1.jpg", Image.JPEG);
 barcode.setContentId("barcode");

 eml.getLinkedResources().addItem(barcode);
 eml.getAlternateViews().addItem(plainView);
 eml.getAlternateViews().addItem(htmlView);

 eml.save("EmbeddedImage_out.msg", SaveOptions.getDefaultMsgUnicode());

Constructors

ConstructorDescription
LinkedResource(String fileName)Initializes a new instance of the LinkedResource class.
LinkedResource(String fileName, String mediaType)Initializes a new instance of the LinkedResource class.
LinkedResource(String fileName, ContentType contentType)Initializes a new instance of the LinkedResource class.
LinkedResource(InputStream contentStream)Initializes a new instance of the LinkedResource class.
LinkedResource(InputStream contentStream, String mediaType)Initializes a new instance of the LinkedResource class.
LinkedResource(InputStream contentStream, ContentType contentType)Initializes a new instance of the LinkedResource class.

Methods

MethodDescription
close()
createLinkedResourceFromString(String content)Creates the linked resource from string.
createLinkedResourceFromString(String content, ContentType contentType)Creates the linked resource from string.
createLinkedResourceFromString(String content, Charset contentEncoding, String mediaType)Creates the linked resource from string.
dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
equals(Object arg0)
getClass()
getContentDisposition()Gets Content-Disposition header
getContentId()Gets or sets the content id.
getContentLink()Gets or sets a URI that the resource must match.
getContentStream()Gets or sets the content stream.
getContentType()Gets or sets the type of the content.
getHeaders()Gets headers collection of attachment.
getTransferEncoding()Gets or sets the transfer encoding.
hashCode()
notify()
notifyAll()
save(OutputStream stream)Saves the specified stream.
save(String fileName)Saves the specified file name.
setContentId(String value)Gets or sets the content id.
setContentLink(URI value)Gets or sets a URI that the resource must match.
setContentStream(InputStream value)Gets or sets the content stream.
setContentType(ContentType value)Gets or sets the type of the content.
setTransferEncoding(int value)Gets or sets the transfer encoding.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

LinkedResource(String fileName)

public LinkedResource(String fileName)

Initializes a new instance of the LinkedResource class.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringThe file name that holds the content for this resource.

LinkedResource(String fileName, String mediaType)

public LinkedResource(String fileName, String mediaType)

Initializes a new instance of the LinkedResource class.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringThe file name that holds the content for this resource.
mediaTypejava.lang.StringInternet media type.

LinkedResource(String fileName, ContentType contentType)

public LinkedResource(String fileName, ContentType contentType)

Initializes a new instance of the LinkedResource class.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringThe file name that holds the content for this resource.
contentTypeContentTypeThe type of content.

LinkedResource(InputStream contentStream)

public LinkedResource(InputStream contentStream)

Initializes a new instance of the LinkedResource class.

Parameters:

ParameterTypeDescription
contentStreamjava.io.InputStreamA stream that contains the content for this resource.

LinkedResource(InputStream contentStream, String mediaType)

public LinkedResource(InputStream contentStream, String mediaType)

Initializes a new instance of the LinkedResource class.

Parameters:

ParameterTypeDescription
contentStreamjava.io.InputStreamA stream that contains the content for this resource.
mediaTypejava.lang.StringInternet media type.

LinkedResource(InputStream contentStream, ContentType contentType)

public LinkedResource(InputStream contentStream, ContentType contentType)

Initializes a new instance of the LinkedResource class.

Parameters:

ParameterTypeDescription
contentStreamjava.io.InputStreamA stream that contains the content for this resource.
contentTypeContentTypeThe type of content.

close()

public void close()

createLinkedResourceFromString(String content)

public static LinkedResource createLinkedResourceFromString(String content)

Creates the linked resource from string.

Parameters:

ParameterTypeDescription
contentjava.lang.StringA string that contains the resource to be included in the email attachment.

Returns: LinkedResource - A LinkedResource object that contains the embedded resource.

createLinkedResourceFromString(String content, ContentType contentType)

public static LinkedResource createLinkedResourceFromString(String content, ContentType contentType)

Creates the linked resource from string.

Parameters:

ParameterTypeDescription
contentjava.lang.StringA string that contains the resource to be included in the email attachment.
contentTypeContentTypeThe type of the content.

Returns: LinkedResource - A LinkedResource object that contains the embedded resource.

createLinkedResourceFromString(String content, Charset contentEncoding, String mediaType)

public static LinkedResource createLinkedResourceFromString(String content, Charset contentEncoding, String mediaType)

Creates the linked resource from string.

Parameters:

ParameterTypeDescription
contentjava.lang.StringA string that contains the resource to be included in the email attachment.
contentEncodingjava.nio.charset.CharsetThe content encoding.
mediaTypejava.lang.StringThe MIME media type of the content.

Returns: LinkedResource - A LinkedResource object that contains the embedded resource.

dispose()

public final void dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getContentDisposition()

public final ContentDisposition getContentDisposition()

Gets Content-Disposition header

Returns: ContentDisposition

getContentId()

public final String getContentId()

Gets or sets the content id.

Value: The content id.

Returns: java.lang.String

public final URI getContentLink()

Gets or sets a URI that the resource must match.

Returns: java.net.URI

getContentStream()

public final InputStream getContentStream()

Gets or sets the content stream.

Value: The content stream.

Returns: java.io.InputStream

getContentType()

public final ContentType getContentType()

Gets or sets the type of the content.

Value: The type of the content.

Returns: ContentType

getHeaders()

public HeaderCollection getHeaders()

Gets headers collection of attachment.

Returns: HeaderCollection

getTransferEncoding()

public final int getTransferEncoding()

Gets or sets the transfer encoding.

Value: The transfer encoding.

Returns: int

hashCode()

public native int hashCode()

Returns: int

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

save(OutputStream stream)

public void save(OutputStream stream)

Saves the specified stream.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamThe stream.

save(String fileName)

public void save(String fileName)

Saves the specified file name.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringName of the file.

setContentId(String value)

public final void setContentId(String value)

Gets or sets the content id.

Value: The content id.

Parameters:

ParameterTypeDescription
valuejava.lang.String
public final void setContentLink(URI value)

Gets or sets a URI that the resource must match.

Parameters:

ParameterTypeDescription
valuejava.net.URI

setContentStream(InputStream value)

public final void setContentStream(InputStream value)

Gets or sets the content stream.

Value: The content stream.

Parameters:

ParameterTypeDescription
valuejava.io.InputStream

setContentType(ContentType value)

public final void setContentType(ContentType value)

Gets or sets the type of the content.

Value: The type of the content.

Parameters:

ParameterTypeDescription
valueContentType

setTransferEncoding(int value)

public final void setTransferEncoding(int value)

Gets or sets the transfer encoding.

Value: The transfer encoding.

Parameters:

ParameterTypeDescription
valueint

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int