Background - I am working on a Lync application which acts as a middle-man in conversations going to specific users. Basically, a call coming in to UserA is forwarded to UserB, but the caller isn't given UserB's details. From her point of view, she converses directly with UserA. Basically, the application manages two calls for each incoming call to UserA:
- from the caller to UserA
- from UserA (via impersonation as the caller) to UserB
Each message is received and is forwarded as is to UserB.
Problem There are a few scenarios in which I wish to give an automatic reply from the system. No problem so far, but I want to set a style for these "system" messages. When chatting in a normal Lync conversation, you are able to select font, color and size, as well as change the direction of the text.
Now, for regular communique between the two parties, I simply pass the messages on untouched - i.e., UserA receives a message from the caller, and the system sends the e.TextBody
to UserB as is (e
is InstantMessageReceivedEventArgs
). I simply call:
instantMessagingFlow.BeginSendInstantMessage(Encoding.UTF8.GetBytes(e.TextBody),
res =>
{
try
{
instantMessagingFlow.EndSendInstantMessage(res);
}
catch(Exception ex)
{
//handle exception
}
});
Now, in this case the formatting get completely lost. I have found no evidence of any sort of style data passed in the InstantMessageReceivedEventArgs
...
I know it's possible to style the IM's using HTML so that sending the message becomes something like:
instantMessagingFlow.BeginSendInstantMessage(new ContentType("text/html"),
Encoding.UTF8.GetBytes("<div style='color: blue;'>" + e.TextBody + "</div>"),
res =>
[...]
This gives me the text in the selected color, but I am having trouble selecting a font, or setting text alignment. No matter what I do, some of the font is displayed in Times New Roman (or is it Segoe UI? Whatever the default is...). I set font using font-family: Arial;
. In some cases, it is simply ignored, but even when it works, setting direction: rtl;
(most of the text is supposed to be right-to-left), or text-align: right;
has no effect whatsoever...
Am I putting incorrect commands? Is there a specific command that I need to use for the text-alignment which isn't text-align
?