APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Caution
The Outlook tasks API is deprecated and will stop returning data on August 20, 2022. Please use the new To Do API. For more information, see To Do APIs in public preview.
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Attachment
{
OdataType = "#microsoft.graph.fileAttachment",
Name = "menu.txt",
AdditionalData = new Dictionary<string, object>
{
{
"contentBytes" , "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
},
},
};
var result = await graphClient.Me.Outlook.Tasks["{outlookTask-id}"].Attachments.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new Attachment();
$requestBody->set@odatatype('#microsoft.graph.fileAttachment');
$requestBody->setName('menu.txt');
$additionalData = [
'contentBytes' => 'bWFjIGFuZCBjaGVlc2UgdG9kYXk=',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->me()->outlook()->tasks()->byTaskId('outlookTask-id')->attachments()->post($requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Import-Module Microsoft.Graph.Users
$params = @{
"@odata.type" = "#microsoft.graph.fileAttachment"
name = "menu.txt"
contentBytes = "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
# A UPN can also be used as -UserId.
New-MgUserOutlookTaskAttachment -UserId $userId -OutlookTaskId $outlookTaskId -BodyParameter $params
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
POST https://graph.microsoft.com/beta/me/outlook/tasks/AAMkADAAAANXbdnAAA=/attachments
Content-type: application/json
{
"@odata.type": "#microsoft.graph.itemAttachment",
"name": "Holiday event",
"item": {
"@odata.type": "microsoft.graph.event",
"subject": "Discuss gifts for children",
"body": {
"contentType": "HTML",
"content": "Let's look for funding!"
},
"start": {
"dateTime": "2020-01-12T18:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2020-01-12T19:00:00",
"timeZone": "Pacific Standard Time"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Attachment
{
OdataType = "#microsoft.graph.itemAttachment",
Name = "Holiday event",
AdditionalData = new Dictionary<string, object>
{
{
"item" , new
{
OdataType = "microsoft.graph.event",
Subject = "Discuss gifts for children",
Body = new
{
ContentType = "HTML",
Content = "Let's look for funding!",
},
Start = new
{
DateTime = "2020-01-12T18:00:00",
TimeZone = "Pacific Standard Time",
},
End = new
{
DateTime = "2020-01-12T19:00:00",
TimeZone = "Pacific Standard Time",
},
}
},
},
};
var result = await graphClient.Me.Outlook.Tasks["{outlookTask-id}"].Attachments.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
ItemAttachment attachment = new ItemAttachment();
attachment.name = "Holiday event";
Event item = new Event();
item.subject = "Discuss gifts for children";
ItemBody body = new ItemBody();
body.contentType = BodyType.HTML;
body.content = "Let's look for funding!";
item.body = body;
DateTimeTimeZone start = new DateTimeTimeZone();
start.dateTime = "2020-01-12T18:00:00";
start.timeZone = "Pacific Standard Time";
item.start = start;
DateTimeTimeZone end = new DateTimeTimeZone();
end.dateTime = "2020-01-12T19:00:00";
end.timeZone = "Pacific Standard Time";
item.end = end;
attachment.item = item;
graphClient.me().outlook().tasks("AAMkADAAAANXbdnAAA=").attachments()
.buildRequest()
.post(attachment);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new Attachment();
$requestBody->set@odatatype('#microsoft.graph.itemAttachment');
$requestBody->setName('Holiday event');
$additionalData = [
'item' => $requestBody = new Item();
$ requestBody->set@odatatype('microsoft.graph.event');
$ requestBody->setSubject('Discuss gifts for children');
$body = new Body();
$ body->setContentType('HTML');
$ body->setContent('Let\'s look for funding!');
$requestBody->setBody($body);
$start = new Start();
$ start->setDateTime('2020-01-12T18:00:00');
$ start->setTimeZone('Pacific Standard Time');
$requestBody->setStart($start);
$end = new End();
$ end->setDateTime('2020-01-12T19:00:00');
$ end->setTimeZone('Pacific Standard Time');
$requestBody->setEnd($end);
$requestBody->setItem($item);
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->me()->outlook()->tasks()->byTaskId('outlookTask-id')->attachments()->post($requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Import-Module Microsoft.Graph.Users
$params = @{
"@odata.type" = "#microsoft.graph.itemAttachment"
name = "Holiday event"
item = @{
"@odata.type" = "microsoft.graph.event"
subject = "Discuss gifts for children"
}
}
# A UPN can also be used as -UserId.
New-MgUserOutlookTaskAttachment -UserId $userId -OutlookTaskId $outlookTaskId -BodyParameter $params
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.