MessageComposer.AddAttachmentContainer
--------------------------------------

Adds an attachment to the email based on a container field.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [MessageComposer](component_MessageComposer.md) | [7.3](newinversion73.md) | ❌ No | ❌ No | ❌ No | ❌ No | ✅ Yes |

MBS( "MessageComposer.AddAttachmentContainer"; Container; Name { ; MimeType } ) 

**MBS**( **"MessageComposer.AddAttachmentContainer"** /\* Adds an attachment to the email based on a container field. \*/  
**$Container**; /\* The container to attach to email. e.g. Attachment::Container \*/   
**$Name**; /\* The name for the attachment. e.g. "sample.pdf" \*/   
**$MimeType**) /\* Optional; The UTI, file extension or mime type to use. e.g. "application/pdf" for PDF files. If missing, we use "application/octet-stream". e.g. "application/octet-stream" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Container | The container to attach to email. | Attachment::Container |  |
| Name | The name for the attachment. | "sample.pdf" |  |
| MimeType | The UTI, file extension or mime type to use. e.g. "application/pdf" for PDF files. If missing, we use "application/octet-stream". | "application/octet-stream" | Optional |

### Result

Returns OK or error.

### Description

Adds an attachment to the email based on a container field.  
You can use [Text.FileExtensionToMimeType](TextFileExtensionToMimeType.md) to find the mime type for a file extension.  
You can use AddAttachment several times to add several attachments.  
### Examples

Adds an attachment:

 Set Variable \[ $FieldName ; Value: Get(ScriptParameter) \]   
Set Variable \[ $Container ; Value: GetField ( $FieldName ) \]   
If \[ IsEmpty ( $container ) = 0 \]   
 Set Variable \[ $path ; Value: GetAsText ( $Container ) \]   
 Set Variable \[ $name ; Value: MBS ( "[Path.LastPathComponent](PathLastPathComponent.md)"; $path ) \]   
 Set Variable \[ $extension ; Value: MBS ( "[Files.FileExtension](FilesFileExtension.md)"; $name ) \]   
 Set Variable \[ $mimeType ; Value: MBS ( "[Text.FileExtensionToMimeType](TextFileExtensionToMimeType.md)"; $extension ) \]   
 #   
 Set Variable \[ $r ; Value: MBS ( "MessageComposer.AddAttachmentContainer"; $container ; $name ; $mimeType ) \]   
End If  
### See also

- [Files.FileExtension](FilesFileExtension.md)
- [MailComposer.AddAttachmentContainer](MailComposerAddAttachmentContainer.md)
- [MessageComposer.AddAttachmentFile](MessageComposerAddAttachmentFile.md)
- [MessageComposer.AttachmentCount](MessageComposerAttachmentCount.md)
- [Path.LastPathComponent](PathLastPathComponent.md)
- [Text.FileExtensionToMimeType](TextFileExtensionToMimeType.md)

### Example Databases

- [iOS/Examples/iOS Message Sending](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/iOS/Examples/iOS%20Message%20Sending.shtml#6ScriptAnchor_)

This function checks for a license.

Created 10th June 2017 , last changed 10th June 2017

  
[Menubar.SetMenuCommandVisible](MenubarSetMenuCommandVisible.md) - [MessageComposer.AddAttachmentFile](MessageComposerAddAttachmentFile.md)

[HTML Version](MessageComposerAddAttachmentContainer.shtml)