Java 8 has reached end of support
and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Java 8
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Java
8 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of Java.
MailService.Attachment (Google App Engine API for Java)
Stay organized with collections
Save and categorize content based on your preferences.
- java.lang.Object
-
- com.google.appengine.api.mail.MailService.Attachment
-
- Enclosing interface:
- MailService
public static class MailService.Attachment
extends java.lang.Object
-
-
Constructor Summary
Constructors
Constructor and Description |
Attachment(java.lang.String fileName,
byte[] data)
Attachments are an optional part of messages, but if present, all
information about them must be provided.
|
Attachment(java.lang.String fileName,
byte[] data,
java.lang.String contentID)
Attachments are an optional part of messages, but if present, all
information about them must be provided.
|
-
Method Summary
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getContentID
public java.lang.String getContentID()
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eMailService.Attachment\u003c/code\u003e class represents an attachment that can be included in email messages sent through the App Engine Mail API.\u003c/p\u003e\n"],["\u003cp\u003eAttachments require both a filename and data, where the filename must have a valid, whitelisted extension, and the data can be an array of zero length but must be present.\u003c/p\u003e\n"],["\u003cp\u003eThe class provides two constructors: one for creating attachments with a filename and data, and another that additionally allows specifying a \u003ccode\u003econtentID\u003c/code\u003e for the attachment.\u003c/p\u003e\n"],["\u003cp\u003eMethods are available to retrieve the attachment's filename (\u003ccode\u003egetFileName\u003c/code\u003e), the raw data content (\u003ccode\u003egetData\u003c/code\u003e), and the content ID (\u003ccode\u003egetContentID\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eConstructing an attachment without a filename or data will result in a \u003ccode\u003ejava.lang.IllegalArgumentException\u003c/code\u003e being thrown.\u003c/p\u003e\n"]]],[],null,["# MailService.Attachment (Google App Engine API for Java)\n\ncom.google.appengine.api.mail\n\nClass MailService.Attachment\n----------------------------\n\n- java.lang.Object\n-\n - com.google.appengine.api.mail.MailService.Attachment\n\n-\n\n Enclosing interface:\n : [MailService](../../../../../com/google/appengine/api/mail/MailService.html \"interface in com.google.appengine.api.mail\")\n\n *** ** * ** ***\n\n \u003cbr /\u003e\n\n ```\n public static class MailService.Attachment\n extends java.lang.Object\n``` \n-\n -\n\n ### Constructor Summary\n\n \u003c!-- --\u003e\n\n -\n\n ### Method Summary\n\n -\n\n ### Methods inherited from class java.lang.Object\n\n`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait` \n-\n -\n\n ### Constructor Detail\n\n\n -\n\n #### Attachment\n\n ```\n public Attachment(java.lang.String fileName,\n byte[] data)\n ``` \n Attachments are an optional part of messages, but if present, all information about them must be provided.\n\n Parameters:\n : `fileName` - The attachment must have a filename associated with it.\n The extension on that filename must be present and white-listed, or\n there will be a failure at send time.\n : `data` - An array with arbitrary byte content. The array must be\n be present, but may be of zero length.\n\n Throws:\n : `java.lang.IllegalArgumentException` - if either fileName or data are missing.\n\n\n -\n\n #### Attachment\n\n ```\n public Attachment(java.lang.String fileName,\n byte[] data,\n java.lang.String contentID)\n ``` \n Attachments are an optional part of messages, but if present, all information about them must be provided.\n\n Parameters:\n : `fileName` - The attachment must have a filename associated with it.\n The extension on that filename must be present and white-listed, or\n there will be a failure at send time.\n : `data` - An array with arbitrary byte content. The array must be\n be present, but may be of zero length.\n : `contentID` - The attachment's content ID. May be null.\n\n Throws:\n : `java.lang.IllegalArgumentException` - if either fileName or data are missing.\n\n \u003c!-- --\u003e\n\n -\n\n ### Method Detail\n\n\n -\n\n #### getFileName\n\n ```\n public java.lang.String getFileName()\n ``` \n Gets the file name of this attachment.\n\n Returns:\n : The file name of this attachment.\n\n\n -\n\n #### getData\n\n ```\n public byte[] getData()\n ``` \n Gets the content of this attachment.\n\n Returns:\n : The raw data of this attachment.\n\n\n -\n\n #### getContentID\n\n ```\n public java.lang.String getContentID()\n ```"]]