# Upload Activity Attachment

> `UiPath.MicrosoftDynamics.Activities.UploadActivityAttachment`

`UiPath.MicrosoftDynamics.Activities.UploadActivityAttachment`

The **Upload Activity Attachment** activity uses the Web API [POST](https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/create-entity-web-api?view=dynamics-ce-odata-9) operation to upload an attachment to an email, appointment, or template activity.

After uploading the attachment, the activity outputs the `String` identifier assigned to the attachment (**AttachmentId**) and the status of the request (success/failure information) in a `ResponseStatus` object (**MicrosoftDynamicsStatus**) that you can use in subsequent activities (e.g., conditional logic).

## How it works

The following steps and message sequence diagram is an example of how the activity works from design time (i.e., the activity dependencies and input/output properties) to run time.

1. Complete the [Setup](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-setup) steps.
2. Add the [Microsoft Dynamics Application Scope](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-scope) activity to your project.
3. Add an activity or run an external process that outputs a activity identifier (e.g., [Insert Record](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-insert-record), [Search Records](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-search-records)).
4. Add the **Upload Activity Attachment** activity inside the **Microsoft Dynamics Application Scope** activity.
5. Enter values for the [Input](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-upload-activity-attachment#upload-activity-attachment) properties.
6. Create and enter a `String` and a `ResponseStatus` variable for the output properties.
   * Your input property values are sent in the Web API [POST](https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/create-entity-web-api?view=dynamics-ce-odata-9) operation request.
   * The operation returns the `String` identifier and `ResponseStatus` values to your output property variables.

     ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-178079-714809bf-92a7f73f.webp)

## Properties

### Common

* **DisplayName** - The display name of the activity. This field supports only strings or `String` variables.

### Input

* **Activity Id** - The identifier assigned to the activity that you want to upload an attachment to. This field supports only `Strings` or `String` variables.
  :::note
  To get the **ActivityId** value, use an activity or run an external process that outputs the activity identifier(e.g., [Insert Record](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-insert-record), [Search Records](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-search-records)). Only activity objects that can be associated with an attachment may be used (i.e., email, appointments, template). If the activity object does not support attachments, the following error is returned: \* *ResponseStatus* { ErrorCode="0x80040203", Message="Attachments can be associated only with e-mail activities, e-mail templates or appointments.", Success=false }
  :::
* **File** - The complete local path to the file that you want to upload. This field supports only strings or `String` variables.

### Misc

* **Private** - If selected, the values of variables and arguments are no longer logged at Verbose level.

### Options

* **MimeType** - Optional mime type of the attached file.

### Output

* **AttachmentId** - The identifier assigned to the attachment that was uploaded. This field supports only `String` variables. To delete an attachment, you can use the **AttachmentId** variable in a [Delete Record](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-delete-record) activity; select the *ActivityMimeAttactment* object.
* **ResponseStatus** - The status of the request (success/failure information). Enter a `ResponseStatus` variable (*UiPath.BAF.Models.ResponseStatus*). The `ResponseStatus` object includes three properties that you can use in other activities.
  + **Success** - `Boolean` - Specifies whether the API request was successful.
  + **ErrorCode** - `String` - The response error if the API request is unsuccessful (**Success**=*False*).
  + **Message** - `String` - The error message.

## Example

The following image shows an example of the activity dependency relationship and input/output property values.

For step-by-step instructions and examples, see the [Quickstart](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-quickstarts) guide.

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-185602-ab3684b2-550b1298.webp)
