Search code examples
c#skype-for-businessucma

How to display image as a reply using UCMA skype for business


I have created an application that connects the user to a chat bot behind the scene. The responses from chat bot when text work fine but I also need to display images when necessary. Does anyone have any direction or code snippet I can use. I have this code that does not work

FileStream fs = File.OpenRead(@"C:\data\logo2.png");
                var fileBytes = new byte[fs.Length];
                fs.Read(fileBytes, 0, fileBytes.Length);

                ContentType ct = new ContentType("image/png");
                ct.CharSet = "UTF-8";

                byte[] bytes1 = Encoding.UTF8.GetBytes(fileBytes.ToString());

                _instantMessagingFlow.BeginSendInstantMessage(ct, bytes1, SendMessageCompleted,
                _instantMessagingFlow);

Solution

  • I was able to resolve it by using MimePartContentDescription(new ContentType("multipart/alternative").

    I cannot paste the working code for propriety reasons - but if you look for MimePartContentDescription(new ContentType("multipart/alternative") you should see be able to read documenation/examples for usage.

    I did have a limitation of displaying image based on size - anything less than 40kb works. Its not a show stopper for me as the images are actually small in my use case. I will mark this as answered for now, but if someone has any idea why the sixe limitation I would love to know.