做开发时参考了http://www.cnblogs.com/cleo/archive/2005/12/29/lcs_webservice.html来做的!

使用RTC的SDK来进行消息的发送!

编程步骤:

1.请安装同时1.2和1.3 ,安装完下载后的MSI包之后,而且要运行
    :\Program Files\RTC Client API v1.2 SDK\INSTALLATION\RtcApiSetup.exe
    :\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcApiSetup.exe
    :\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcSxSPolicies.msi
   以上3个全部要安装,不是说安装1.3就不需要安装1.2了,而且要按照这个顺序,否则可能不能成功。
最好重新启动电脑吧
.

 DownLoad RTC Client API
        http://msdn.microsoft.com/downloads/list/clientapi.asp

        Microsoft Windows Real-Time Communications Client API SDK v1.3
       The Microsoft Windows Real-Time Communications Software Development Kit 1.3 provides information, samples, and tools regarding the additional features of the Real-Time Communications 1.3 API. Additional features include: enhanced multiple points of presence support, support for Microsoft Office Live Communications Server 2005, additional client security options, and marshalling support.

        Microsoft Real-time Communications Client Software Development Kit (SDK) v1.2
        The Microsoft Real-time Communications Client SDK provides documentation, sample code and other tools that allow developers to build real-time communication applications, or integrate real-time communication functionality into existing applications.
Note: To execute samples or applications upon any development or test machine, install the SDK and then run RTCAPISETUP.EXE to install the Microsoft Real-time Communications Client API binaries. This executable can be found within the "Installation" sub-directory.

2.编写cs代码:

using System;
using System.Collections.Generic;
using System.Text;

namespace Newsease.OA.Util
{
    public class SendMssageUtil
    {
        public static void SendMsg(string strDestURI, string strMsg, string strDestName)
        {

            string account = @"gy.zj\admin";     //发送消息的管理员
            string password = "123456";
            string uri = "sip:admin@gy.zj";    //发送消息的管理员的sip地址
            string addr = "zjgy-d42.gy.zj:5060";    //lcs2005服务器的fqdn
            string domain = "gy.zj";    //主域的名称
            string strMsgHeader = null;
            int lCookie = 0;
            try
            {

                SendMessage(account, password, uri, addr, domain,
                     strMsgHeader, strMsg, lCookie, strDestURI, strDestName);
            }
            catch (Exception ex)
            {
                System.Diagnostics.EventLog.WriteEntry("LCSClass", ex.ToString());
              
            }
            return;
        }

        public static void SendMessage(string account, string password, string uri, string addr, string domain,
     string strMsgHeader, string strMsg, int lCookie, string strDestURI, string strDestName)
        {
            try
            {
                RTCCORELib.RTCClient objRTCClient;
                RTCCORELib.IRTCSession objSession;
                objRTCClient = new RTCCORELib.RTCClient();
                objRTCClient.Initialize();
                createEnableProfile(objRTCClient, account, password, uri, addr, domain);
                objSession = objRTCClient.CreateSession(RTCCORELib.RTC_SESSION_TYPE.RTCST_MULTIPARTY_IM, null, null, 0);
                objSession.AddParticipant(strDestURI, strDestName);
                objSession.SendMessage(strMsgHeader, strMsg, lCookie);
            }
            catch (Exception ex)
            {
                System.Diagnostics.EventLog.WriteEntry("LCSClass", ex.ToString());
            }
        }

        private static void createEnableProfile(RTCCORELib.RTCClient objRTCClient, string account, string password, string uri, string addr, string domain)
        {
            string s = "";
            s += "<provision key=\"{566E246F-9978-4434-83BF-3E47BCCFF466}\" name=\"" + domain + "\">";
            s += "<user account=\"" + account + "\" password=\"" + password + "\" uri=\"" + uri + "\" />";
            s += "<sipsrv addr=\"" + addr + "\" protocol=\"tcp\" role=\"proxy\">";
            s += "<session party=\"first\" type=\"pc2pc\" />";
            s += "<session party=\"first\" type=\"pc2ph\" />";
            s += "<session party=\"first\" type=\"im\" />";
            s += "</sipsrv>";
            s += "<sipsrv addr=\"" + addr + "\" protocol=\"tcp\" role=\"registrar\" />";
            s += "</provision>";

            RTCCORELib.IRTCProfile2 objProfile;
            RTCCORELib.IRTCClientProvisioning2 objProvisioning;
            try
            {
                objProvisioning = (RTCCORELib.IRTCClientProvisioning2)objRTCClient;
                objProfile = (RTCCORELib.IRTCProfile2)objProvisioning.CreateProfile(s);
                objProvisioning.EnableProfile(objProfile, 0xF);
            }
            catch (Exception ex)
            {
                System.Diagnostics.EventLog.WriteEntry("LCSClass", ex.ToString());
            }
            return;
        }

    }
}

注意一定要引用RTCCORELib.dll 
路径可能是:C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Networking.RtcDll_6595b64144ccf1df_5.2.2.1_x-ww_d6bd8b93\RTCCORELib.dll