Class Attachment
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ไฟล์แนบ
แสดงไฟล์แนบที่สร้างขึ้นโดยส่วนเสริม ซึ่งสามารถใช้ในบริบทของผลิตภัณฑ์การขยายความสามารถของ Google ต่างๆ เพื่อสร้างไฟล์แนบใหม่ เช่น สําหรับกิจกรรมในปฏิทิน
const attachment = CardService.newAttachment()
.setResourceUrl('https://fakeresourceurl.com')
.setTitle('Attachment title')
.setMimeType('text/html')
.setIconUrl('https://fakeresourceurl.com/iconurl.png');
เอกสารประกอบโดยละเอียด
setIconUrl(iconUrl)
ตั้งค่า URL ไอคอนของไฟล์แนบ
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
iconUrl | String | ที่อยู่ URL ของไอคอนไฟล์แนบ |
รีเทิร์น
Attachment
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setMimeType(mimeType)
ตั้งค่าประเภท MIME สำหรับไฟล์แนบ
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
mimeType | String | ประเภท MIME ของเนื้อหาในทรัพยากรไฟล์แนบ |
รีเทิร์น
Attachment
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setResourceUrl(resourceUrl)
ตั้งค่า URL ของทรัพยากรสําหรับไฟล์แนบ
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
resourceUrl | String | ที่อยู่ URL ของทรัพยากร |
รีเทิร์น
Attachment
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setTitle(title)
ตั้งชื่อไฟล์แนบ
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
title | String | ชื่อไฟล์แนบ |
รีเทิร์น
Attachment
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eRepresents attachments generated by add-ons in Google products like Calendar.\u003c/p\u003e\n"],["\u003cp\u003eAllows setting the attachment's title, resource URL, MIME type, and icon URL.\u003c/p\u003e\n"],["\u003cp\u003eProvides methods for customization, including \u003ccode\u003esetIconUrl\u003c/code\u003e, \u003ccode\u003esetMimeType\u003c/code\u003e, \u003ccode\u003esetResourceUrl\u003c/code\u003e, and \u003ccode\u003esetTitle\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAll customization methods return the Attachment object itself for method chaining.\u003c/p\u003e\n"]]],[],null,["# Class Attachment\n\nAttachment\n\nRepresents an attachment created by an add-on. This can be used within the context of different\nGoogle extensibility products to generate new attachments, such as for Calendar events.\n\n```javascript\nconst attachment = CardService.newAttachment()\n .setResourceUrl('https://fakeresourceurl.com')\n .setTitle('Attachment title')\n .setMimeType('text/html')\n .setIconUrl('https://fakeresourceurl.com/iconurl.png');\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|--------------------------------------------------------|-----------------|-------------------------------------------|\n| [setIconUrl(iconUrl)](#setIconUrl(String)) | [Attachment](#) | Sets the icon URL for the attachment. |\n| [setMimeType(mimeType)](#setMimeType(String)) | [Attachment](#) | Sets the MIME type for the attachment. |\n| [setResourceUrl(resourceUrl)](#setResourceUrl(String)) | [Attachment](#) | Sets the resource URL for the attachment. |\n| [setTitle(title)](#setTitle(String)) | [Attachment](#) | Sets the title for the attachment. |\n\nDetailed documentation\n----------------------\n\n### `set``Icon``Url(iconUrl)`\n\nSets the icon URL for the attachment.\n\n#### Parameters\n\n| Name | Type | Description |\n|-------------|----------|-----------------------------------------|\n| `icon``Url` | `String` | The URL address of the attachment icon. |\n\n#### Return\n\n\n[Attachment](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Mime``Type(mimeType)`\n\nSets the MIME type for the attachment.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------|----------|----------------------------------------------------------|\n| `mime``Type` | `String` | The MIME type of the content in the attachment resource. |\n\n#### Return\n\n\n[Attachment](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Resource``Url(resourceUrl)`\n\nSets the resource URL for the attachment.\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------------|----------|--------------------------------|\n| `resource``Url` | `String` | The URL address of a resource. |\n\n#### Return\n\n\n[Attachment](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Title(title)`\n\nSets the title for the attachment.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|----------|------------------------------|\n| `title` | `String` | The title of the attachment. |\n\n#### Return\n\n\n[Attachment](#) --- This object, for chaining."]]