/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.mail;

import java.net.URL;

This class models an email attachment. Used by MultiPartEmail.
Since:1.0
/** * This class models an email attachment. Used by MultiPartEmail. * * @since 1.0 */
public class EmailAttachment {
Definition of the part being an attachment.
/** Definition of the part being an attachment. */
public static final String ATTACHMENT = javax.mail.Part.ATTACHMENT;
Definition of the part being inline.
/** Definition of the part being inline. */
public static final String INLINE = javax.mail.Part.INLINE;
The name of this attachment.
/** The name of this attachment. */
private String name = "";
The description of this attachment.
/** The description of this attachment. */
private String description = "";
The path to this attachment (ie c:/path/to/file.jpg).
/** The path to this attachment (ie c:/path/to/file.jpg). */
private String path = "";
The HttpURI where the file can be got.
/** The HttpURI where the file can be got. */
private URL url;
The disposition.
/** The disposition. */
private String disposition = EmailAttachment.ATTACHMENT;
Get the description.
Returns:A String.
Since:1.0
/** * Get the description. * * @return A String. * @since 1.0 */
public String getDescription() { return description; }
Get the name.
Returns:A String.
Since:1.0
/** * Get the name. * * @return A String. * @since 1.0 */
public String getName() { return name; }
Get the path.
Returns:A String.
Since:1.0
/** * Get the path. * * @return A String. * @since 1.0 */
public String getPath() { return path; }
Get the URL.
Returns:A URL.
Since:1.0
/** * Get the URL. * * @return A URL. * @since 1.0 */
public URL getURL() { return url; }
Get the disposition.
Returns:A String.
Since:1.0
/** * Get the disposition. * * @return A String. * @since 1.0 */
public String getDisposition() { return disposition; }
Set the description.
Params:
  • desc – A String.
Since:1.0
/** * Set the description. * * @param desc A String. * @since 1.0 */
public void setDescription(final String desc) { this.description = desc; }
Set the name.
Params:
  • aName – A String.
Since:1.0
/** * Set the name. * * @param aName A String. * @since 1.0 */
public void setName(final String aName) { this.name = aName; }
Set the path to the attachment. The path can be absolute or relative and should include the filename.

Example: /home/user/images/image.jpg
Example: images/image.jpg

Params:
  • aPath – A String.
Since:1.0
/** * Set the path to the attachment. The path can be absolute or relative * and should include the filename. * <p> * Example: /home/user/images/image.jpg<br> * Example: images/image.jpg * * @param aPath A String. * @since 1.0 */
public void setPath(final String aPath) { this.path = aPath; }
Set the URL.
Params:
  • aUrl – A URL.
Since:1.0
/** * Set the URL. * * @param aUrl A URL. * @since 1.0 */
public void setURL(final URL aUrl) { this.url = aUrl; }
Set the disposition.
Params:
  • aDisposition – A String.
Since:1.0
/** * Set the disposition. * * @param aDisposition A String. * @since 1.0 */
public void setDisposition(final String aDisposition) { this.disposition = aDisposition; } }