使用 UCMA 2.0 发送格式化文本

发布于 2024-07-22 11:05:54 字数 94 浏览 4 评论 0原文

有人成功使用 UCMA 2.0 sdk 通过即时消息流发送格式化文本吗?

MSDN 上似乎没有很好的记录。 有没有什么例子? 有什么书讲这个的吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅听莫相离 2024-07-29 11:05:54

今天早些时候我自己在工作项目中遇到了这个问题。 我目前无法访问我的代码,但它本质上可以通过执行以下操作...

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。

感谢“mdip”发布上述代码解决方案...

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

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

小草泠泠 2024-07-29 11:05:54

我的理解是消息提示只是字符串。 如果您想向字符串添加格式,建议在提示中使用常见的 html 格式,然后将收到的提示输入到 HTML 感知控件中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文