There are 2 ways to achieve that goal.
First one, pass image url to channel
if my source url is like
http://abc.com/dog.png
var reply = context.MakeMessage();
reply.Attachments.Add(new Attachment
{
ContentType = "image/png",
});
Pass base64 encoded image data
Stream fs = File.OpenRead("C:\\dog.png");
byte[] img = fs.ToArray();
string ima64 = Convert.ToBase64String(img);
var reply = context.MakeMessage();
reply.Attachments.Add(new Attachment
{
ContentUrl = $"data:image/png;base64,{ima64}",
ContentType = "image/png",
});
Or you can add image into Card
var card = new HeroCard
{
Title = employee.Name,
Text = $"Title: {employee.Title}, Phone: {employee.PhoneNumber}",
Images = new List<CardImage>() { new CardImage { Url = $"data:image/png;base64,{image}" } },
}.ToAttachment();
留言
張貼留言