Actionable Email Developer Dashboard:
Source:
Get started with actionable messages in Office 365: https://learn.microsoft.com/en-us/outlook/actionable-messages/get-started
Register your service with the actionable email developer dashboard: https://learn.microsoft.com/en-us/outlook/actionable-messages/email-dev-dashboard
1. Create Provider in ''Actionable Email Developer Dashboard - https://outlook.office.com/connectors/oam/publish "
2. Save "Provider Id (originator)" in notepad.
3. Approve submitted provider here: https://outlook.office.com/connectors/oam/admin
4. Prepare Json as below:
2. Save "Provider Id (originator)" in notepad.
3. Approve submitted provider here: https://outlook.office.com/connectors/oam/admin
4. Prepare Json as below:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="application/adaptivecard+json">{
"type": "AdaptiveCard",
"version": "1.0",
"hideOriginalBody": true,
"originator": "Provider Id (originator) : GUID from Previous step",
"body": [
{
"type": "TextBlock",
"text": "Visit the Outlook Dev Portal",
"size": "large"
},
{
"type": "TextBlock",
"text": "Click **Learn More** to learn more about Actionable Messages!"
},
{
"type": "Input.Text",
"id": "feedbackText",
"placeholder": "Let us know what you think about Actionable Messages"
}
],
"actions": [
{
"type": "Action.Http",
"title": "Send Feedback",
"method": "POST",
"url": "https://...",
"body": "{{feedbackText.value}}"
},
{
"type": "Action.OpenUrl",
"title": "Learn More",
"url": "https://learn.microsoft.com/outlook/actionable-messages"
}
]
}
</script>
</head>
<body>
Visit the <a href="https://learn.microsoft.com/outlook/actionable-messages">Outlook Dev Portal</a> to learn more about Actionable Messages.
</body>
</html>
C# Code:
OutPut:
C# Code:
using Azure.Identity;
using Microsoft.Graph;
using Microsoft.Graph.Models;
using Microsoft.Graph.Users.Item.SendMail;
public class Program
{
public static async Task Main(string[] args)
{
var clientId = "6e4110e7-e5b0d411db60";
var tenantId = "bb55f134-82bf54373c6d";
var clientSecret = "imx8Q~Q~AHcGN";
var userFromEmail = "user1@test.onmicrosoft.com";
var userToEmails = "user2@test.onmicrosoft.com,user3@test.onmicrosoft.com";
var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
var graphClient = new GraphServiceClient(credential);
string adaptiveCardJson = @"<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<script type='application/adaptivecard+json'>{
'type': 'AdaptiveCard',
'version': '1.0',
'hideOriginalBody': true,
'originator': 'a115aabe-03994fbaf1d',
'body': [
{
'type': 'TextBlock',
'text': 'Visit the Outlook Dev Portal',
'size': 'large'
},
{
'type': 'TextBlock',
'text': 'Click **Learn More** to learn more about Actionable Messages!'
},
{
'type': 'Input.Text',
'id': 'feedbackText',
'placeholder': 'Let us know what you think about Actionable Messages'
}
],
'actions': [
{
'type': 'Action.Http',
'title': 'Send Feedback',
'method': 'POST',
'url': 'https://...',
'body': '{{feedbackText.value}}'
},
{
'type': 'Action.OpenUrl',
'title': 'Learn More',
'url': 'https://learn.microsoft.com/outlook/actionable-messages'
}
]
}
</script>
</head>
<body>
Visit the <a href='https://learn.microsoft.com/outlook/actionable-messages'>Outlook Dev
Portal</a> to learn more about Actionable Messages.
</body>
</html>";
List<string> userToEmailList = new List<string>(userToEmails.Split(','));
var message = new Message
{
Subject = "Test Subject",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = $"{adaptiveCardJson}"
},
ToRecipients = userToEmailList.Select(email => new Recipient { EmailAddress =
new EmailAddress { Address = email } }).ToList(),
};
var sendMailRequest = new SendMailPostRequestBody { Message = message };
await graphClient.Users[userFromEmail].SendMail.PostAsync(sendMailRequest);
Console.ReadKey();
}
}
OutPut:
No comments:
Post a Comment