views:

174

answers:

2

Has anyone been successful in sending formatted text over an Instant Message flow using the UCMA 2.0 sdk?

It doesn't seem to be very well documented on MSDN. Are there any examples out there? Any books that talk about this?

A: 

My understanding is that message prompts are simply strings. If you want to add formatting to a string, a suggestion could be to use common html formatting in the prompt then pump the prompt received into an HTML aware control.

ahmedel
+2  A: 

Ran into this issue myself earlier today on a project at work. I don't have my code accessible to me at the moment, but it's essentially capable by doing the following...

MimePartContentDescription text;
MimePartContentDescription html;
MimePartContentDescription package;

text = new MimePartContentDescription(
    new ContentType("text/plain"),
    Encoding.UTF8.GetBytes(message_text) );

html = new MimePartContentDescription(
    new ContentType("text/html"), 
    Encoding.UTF8.GetBytes(message_html) );

package = new MimePartContentDescription(
    new ContentType("multipart/alternative"), null
);

package.Add(html);
package.Add(text);

// Call BeginSendMessage ... SendMessageCompleted is async callback.
imFlow.BeginSendMessage(package.ContentType, package.GetBody, SendMessageCompleted, imFlow)

This method wraps two versions of the message into a single 'package' (if you will) that will degrade gracefully, providing the plain text version to clients that cannot handle the HTML, or will provide the HTML if the client supports it.

Credit goes to 'mdip' for posting the above code solution...

http://social.msdn.microsoft.com/Forums/en/ucmanagedsdk/thread/c532bbb9-f593-4443-85af-4e0708b8532c

invenetix