如何通过电子邮件发送简单的自适应卡片? [英] How to send a simple adaptive card via email?

查看:167
本文介绍了如何通过电子邮件发送简单的自适应卡片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了有关自适应卡片和可操作消息的文档.我想通过电子邮件发送自适应卡片并在 Outlook 中查看.

I've taken a look at the documentation for adaptive cards and actionable messages. I want to send an adaptive card via email and view it in outlook.

https://docs.microsoft.com/en-us/outlook/actionable-messages/actionable-messages-via-email

我可以使用卡片游乐场(https://messagecardplayground.azurewebsites.net/)向我自己发送一封带有自适应卡片的电子邮件(使用右上角的按钮),并且显示正确.

I am able to use the card playground (https://messagecardplayground.azurewebsites.net/) to send an email to myself with an adaptive card (using the button in the top right), and it renders correctly.

我读到的关于这些自适应卡的所有内容都让人觉得您可以通过电子邮件发送 html 标记(请参阅第一个链接).但是,当我尝试从该页面发送示例 html(带有所有 html 标签,或仅带有 script 标签)时,不会创建自适应卡,并且自适应卡调试器加载项也不会注意到任何内容.

Everything I read about these adaptive cards makes it sound like you can just send the html markup via email (see first link). However, when I try sending the example html from that page (either with all the html tags, or just with the script tag), an adaptive card is not created, and the adaptive card debugger add-in doesn't notice anything either.

我如何自己通过电子邮件发送自适应卡片?

How can I send an adaptive card via email myself?

推荐答案

仍然不确定我是否能够通过 Outlook 客户端(或任何其他邮件客户端)完成此操作,但我可以使用一个简单的通过 Outlook 的 SMTP 服务器发送电子邮件的 C# 程序.

Still not sure if I would be able to do this through an Outlook client (or any other mail client), but I was able to do it using a simple C# program that sends an email through Outlook's SMTP server.

MailMessage mail = new MailMessage("outlookemail@domain.com", "outlookemail@domain.com");
SmtpClient client = new SmtpClient();
string Body = System.IO.File.ReadAllText(@"C:\fullpathhere\test.html");
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Host = "smtp-mail.outlook.com";
client.EnableSsl = true;
client.Timeout = 10000;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("outlookemail@domain.com", "password");
mail.IsBodyHtml = true;
mail.Subject = "Actionable Message Test Email";
mail.Body = Body;
client.Send(mail);

test.html 文件只是 https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference.

The test.html file is just the full HTML from the bottom of https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference.

请记住,大多数 Outlook 客户端无法呈现自适应卡片,只能使用可操作的消息.不过,Outlook 365 的在线客户端可以呈现它们.

Keep in mind most Outlook clients can't render adaptive cards and can only use actionable messages. Outlook 365's online client can render them though.

这篇关于如何通过电子邮件发送简单的自适应卡片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆