Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending formatted text with UCMA 2.0

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?

like image 635
dmo Avatar asked Nov 05 '22 21:11

dmo


1 Answers

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

like image 116
William Holroyd Avatar answered Nov 14 '22 23:11

William Holroyd