发送格式的文本与UCMA 2.0 [英] Sending formatted text with UCMA 2.0

查看:125
本文介绍了发送格式的文本与UCMA 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人成功地在超过使用UCMA 2.0 SDK即时信息流发送格式的文本?

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

这似乎并没有被很好的记录在MSDN上。是否有任何的例子在那里?那说说这什么书?

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

推荐答案

今天早些时候遇到了这个问题,我在工作的项目。我没有我的代码给我访问的时刻,但它是通过执行以下操作...

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)

这方法包装邮件的两个版本到一个单一的'包'(如果你愿意),将优雅降级,提供了纯文字版本的客户端不能处理HTML,或者如果客户端支持,将提供HTML

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.

幸得MDIP张贴上面的代码解决方案...

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

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

这篇关于发送格式的文本与UCMA 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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