C# 腾讯通发送消息通知WCF服务源码
/// <summary>/// 发送消息
/// </summary>
/// <param name="IP">IP地址</param>
/// <param name="Port">端口</param>
/// <param name="ShowTime">消息停留时间(毫秒)</param>
/// <param name="Receivers">接受者 (不填则发送给所有人,多个接收者用";"号分开)</param>
/// <param name="MsgTitle">消息标题</param>
/// <param name="MsgContent">消息内容</param>
/// <returns>是否发送成功</returns>
public bool SendNotify(string ShowTime, string Receivers, string MsgTitle, string MsgContent)
{
try
{
RootObj = new RTXSAPIRootObj(); //创建根对象
RootObj.ServerIP = System.Configuration.ConfigurationManager.AppSettings["RtxIp"]; //设置服务器IP
RootObj.ServerPort = Convert.ToInt16(System.Configuration.ConfigurationManager.AppSettings["RtxPort"]); //设置服务器端口
RootObj.SendNotify(Receivers, MsgTitle, Convert.ToInt32(ShowTime), MsgContent); //发送消息
return true;
}
catch (COMException ex)
{
errLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error);
return false;
}
}
/// <summary>
/// 发送短信
/// </summary>
/// <param name="IP">服务器IP</param>
/// <param name="Port">服务器端口</param>
/// <param name="Sender">发送者</param>
/// <param name="Pwd">发送者密码</param>
/// <param name="Receivers">接受者 (不填则发送给所有人,多个接收者用";"号分开)</param>
/// <param name="Content">短信内容</param>
/// <param name="SessionID">SessionID System.Guid{F41886B6-D593-4868-A25E-377C8727D7B6}</param>
/// <returns>是否发送成功</returns>
public bool SendIM(string Sender, string Pwd, string Receivers, string Content, string SessionID)
{
try
{
RootObj = new RTXSAPIRootObj(); //创建根对象
RootObj.ServerIP = System.Configuration.ConfigurationManager.AppSettings["RtxIp"]; //设置服务器IP
RootObj.ServerPort = Convert.ToInt16(System.Configuration.ConfigurationManager.AppSettings["RtxPort"]); //设置服务器端口
if (SessionID == "")
{
SessionID = @"{" + System.Guid.NewGuid().ToString() + @"}";
}
RootObj.SendIM(Sender, Pwd, Receivers, Content, SessionID);
return true;
}
catch (COMException ex)
{
errLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error);
return false;
}
}
http://download.csdn.net/detail/labppz/6698995
页:
[1]