This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with Attachments in Outlook Mail

Overview

The following operations allow you to work with attachments. Click an operation name to see details on how to use it. 

For a sample proxy service that illustrates how to work with attachments, see Sample configuration.

OperationDescription

createAttachment

Create an attachment

deleteAttachment

Delete a message attachment

getAttachment

Get an attachment

getAttachmentCollection

Get the attachments

Operation details

This section provides further details on the operations related to discussions.

Create Attachment

 The createAttachment operation creates a file attachment or create an item attachment for a message.

createAttachment
<outlookmail.createAttachment>
    <messageId>{$ctx:messageId}</messageId>
    <oDataType>{$ctx:oDataType}</oDataType>
    <name>{$ctx:name}</name>
    <contentBytes>{$ctx:contentBytes}</contentBytes>
</outlookmail.createAttachment>
Properties

messageId : Required -The ID of the message to create an attachment.

oDataType : Required -Open Data Protocol, is a protocol for transferring data over the Internet.(#Microsoft.OutlookServices.FileAttachment)
name : Required -The name of the attachment.
contentBytes : Required -The binary contents of the file.

Sample request
Following is a sample REST/JSON request that can be handled by the createAttachment operation.

 

Sample Request for createAttachment
{
   "apiUrl":"https://outlook.office.com/api",
   "apiVersion":"v2.0",
   "accessToken":"accesstoken",
   "refreshToken":"refreshtoken",
   "clientSecret":"K+M5n5OidY4hJ",
   "clientId":"dec93ce7-dd0f",
   "resource":"https://outlook.office.com/",
   "redirectUri":"http://www.wso2.com",
   "registryPath":"Connector/OutlookMailRegPath",
   "intervalTime":"",
   "messageId":"AAMkADY2YWY5NmMw",
   "oDataType":"#Microsoft.OutlookServices.FileAttachment",
   "name":"TET.txt",
   "contentBytes":"bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
 

Delete Attachment

 The deleteAttachment operation deletes a message attachment. 

deleteAttachment
<outlookmail.deleteAttachment>
    <messageId>{$ctx:messageId}</messageId>
    <attachmentId>{$ctx:attachmentId}</attachmentId>
</outlookmail.deleteAttachment>
Properties

messageId : Required -The ID of the message to delete an attachment.

attachmentId : Required -The attachment ID to delete .

Sample request

 Following is a sample REST/JSON request that can be handled by the deleteAttachment operation.

Sample Request for deleteAttachment
{
   "apiUrl":"https://outlook.office.com/api",
   "apiVersion":"v2.0",
   "accessToken":"accesstoken",
   "refreshToken":"refreshtoken",
   "clientSecret":"K+M5n5OidY4hJ",
   "clientId":"dec93ce7-dd0f",
   "resource":"https://outlook.office.com/",
   "redirectUri":"http://www.wso2.com",
   "registryPath":"Connector/OutlookMailRegPath",
   "intervalTime":"",
   "messageId":"AAMkADY2YWY5NmMw",
   "attachmentId":"AAMkADY2YWY5Nm"
}


Get Attachment

 The getAttachment operation gets an attachment from a particular message. 

getAttachment
 <outlookmail.getAttachment>
     <messageId>{$ctx:messageId}</messageId>
     <attachmentId>{$ctx:attachmentId}</attachmentId>
 </outlookmail.getAttachment>
Properties

messageId : Required -The ID of the message to delete an attachment.

attachmentId : Required -The attachment ID to get.

Sample request

 Following is a sample REST/JSON request that can be handled by the getAttachment operation.

Sample Request for getAttachment
{
   "apiUrl":"https://outlook.office.com/api",
   "apiVersion":"v2.0",
   "accessToken":"accesstoken",
   "refreshToken":"refreshtoken",
   "clientSecret":"K+M5n5OidY4hJ",
   "clientId":"dec93ce7-dd0f",
   "resource":"https://outlook.office.com/",
   "redirectUri":"http://www.wso2.com",
   "registryPath":"Connector/OutlookMailRegPath",
   "intervalTime":"",
   "messageId":"AAMkADY2YWY5NmMw",
   "attachmentId":"AAMkADY2YWY5Nm"
}

 

Get Attachment Collection

 The getAttachmentCollection operation gets the attachments from a particular message. 

getAttachmentCollection
<outlookmail.getAttachmentCollection>
    <messageId>{$ctx:messageId}</messageId>
</outlookmail.getAttachmentCollection>
Properties

messageId : Required -The ID of the message to delete an attachment.

Sample request

 Following is a sample REST/JSON request that can be handled by the getAttachmentCollection operation.

Sample request for getAttachmentCollection
{
   "apiUrl":"https://outlook.office.com/api",
   "apiVersion":"v2.0",
   "accessToken":"accesstoken",
   "refreshToken":"refreshtoken",
   "clientSecret":"K+M5n5OidY4hJ",
   "clientId":"dec93ce7-dd0f",
   "resource":"https://outlook.office.com/",
   "redirectUri":"http://www.wso2.com",
   "registryPath":"Connector/OutlookMailRegPath",
   "intervalTime":"",
   "messageId":"AAMkADY2YWY5NmMw"
}

 

Sample configuration

Following is a sample proxy service that illustrates how to connect to Outlook Mail with the init operation and use the createAttachment operation. The sample request for this proxy can be found in createAttachment sample request.

Sample Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
 name="outLook_CreateAttachment"
 transports="https,http"
 statistics="disable"
 trace="disable"
 startOnLoad="true">
 <target>
 <inSequence>
 <property name="apiUrl" expression="json-eval($.apiUrl)"/>
 <property name="accessToken" expression="json-eval($.accessToken)"/>
 <property name="messageId" expression="json-eval($.messageId)"/>
 <property name="oDataType" expression="json-eval($.oDataType)"/>
 <property name="name" expression="json-eval($.name)"/>
 <property name="contentBytes" expression="json-eval($.contentBytes)"/>
 <property name="apiVersion" expression="json-eval($.apiVersion)"/>
 <property name="refreshToken" expression="json-eval($.refreshToken)"/>
 <property name="clientSecret" expression="json-eval($.clientSecret)"/>
 <property name="clientId" expression="json-eval($.clientId)"/>
 <property name="resource" expression="json-eval($.resource)"/>
 <property name="redirectUri" expression="json-eval($.redirectUri)"/>
 <property name="registryPath" expression="json-eval($.registryPath)"/>
 <property name="intervalTime" expression="json-eval($.intervalTime)"/>
 <outlookmail.init>
 <apiUrl>{$ctx:apiUrl}</apiUrl>
 <accessToken>{$ctx:accessToken}</accessToken>
 <apiVersion>{$ctx:apiVersion}</apiVersion>
 <refreshToken>{$ctx:refreshToken}</refreshToken>
 <clientSecret>{$ctx:clientSecret}</clientSecret>
 <clientId>{$ctx:clientId}</clientId>
 <resource>{$ctx:resource}</resource>
 <redirectUri>{$ctx:redirectUri}</redirectUri>
 <registryPath>{$ctx:registryPath}</registryPath>
 <intervalTime>{$ctx:intervalTime}</intervalTime>
 </outlookmail.init>
 <outlookmail.createAttachment>
 <messageId>{$ctx:messageId}</messageId>
 <oDataType>{$ctx:oDataType}</oDataType>
 <name>{$ctx:name}</name>
 <contentBytes>{$ctx:contentBytes}</contentBytes>
 </outlookmail.createAttachment>
 <respond/>
 </inSequence>
 </target>
 <description/>
</proxy>