ajax(Tibco) 与 SQL server 2005(9)

好久没有动TIBCO GI了.今天试了一下想用AJAX(TIBCO)发送邮件,谁知却没有找到相关的类或ACTIVEX,后来又想到何不利用SQL SERVER 2005 来发送邮件,一试之下果然可以.
 
第一步,先建好存储过程,再发表成SOAP服务:
 
USE [BBSdataBase]
GO
/****** 对象:  StoredProcedure [dbo].[SendMail]    脚本日期: 07/31/2008 19:52:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:  <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[SendMail]
 -- Add the parameters for the stored procedure here
 @TO nchar(50),
 @CC nchar(50),
 @StrSubject nchar(100),
 @StrBody ntext
AS
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;
   EXEC msdb.dbo.sp_send_dbmail
 @profile_name ='SendMailBy163.com',
    @recipients=@TO,
    @subject = @StrSubject,
    @body = @StrBody,
    @body_format = 'HTML' ;
END
 
 
 
第三步,建好窗口,上图先.:
 
 
建窗体的方法,我以前有讲过,这里不多说了.
 
第二步,建好XML文件的映射.如图:
 
 
 
第三步,写JS代码:
 
//  ---------------------------------------
/* 发送邮件 */
FrmSendMail_SendMail= function() {
  // return jsx3.ide.debug();
   var objService = BBS2.loadResource("FrmSendMail_xml_");
   objService.setOperation("SendMail");
   // objService.setEndpointURL(proxy.convertURI(objService.getEndpointURL()));
   objService.subscribe(jsx3.net.Service.ON_SUCCESS, FrmSendMail_SendMail_onUserSuccess);
   objService.subscribe(jsx3.net.Service.ON_ERROR, FrmSendMail_SendMail_onUserError);
   objService.subscribe(jsx3.net.Service.ON_INVALID, FrmSendMail_SendMail_onUserInvalid);
   objService.doCall();
}
//-------------------------------------------
FrmSendMail_SendMail_onUserSuccess = function(objEvent) {
   // return jsx3.ide.debug();
      // 新贴完成, 关闭
}
//--------------------------------------------
FrmSendMail_SendMail_onUserError = function(objEvent) {
   //* * * * * * * * * * * * * 错?~ * * * * * * * * * * * * * * * *
   // return jsx3.ide.debug();
   var myStatus = objEvent.target.getRequest().getStatus();
   var responseXML = objEvent.target.getInboundDocument();
   BBS2.alert("发生错误", "呼叫服务器失败! HTTP状态代码是: " + myStatus + "", function(){
      this.getAncestorOfType(jsx3.gui.Dialog).doClose();
   }
   , "确定");
}
//----------------------------------------------
FrmSendMail_SendMail_onUserInvalid = function(objEvent) {
   var myStatus = objEvent.target.getRequest().getStatus();
   var responseXML = objEvent.target.getInboundDocument();
   BBS2.alert("发生错误", "非法呼叫服务器失败! HTTP状态代码是: " + myStatus + "", function(){
      this.getAncestorOfType(jsx3.gui.Dialog).doClose();
   }
   , "确定");
}
 
然后再把FrmSendMail_SendMail过程与发送按钮挂勾.成功了.测试吧.

你可能感兴趣的:(数据库,Ajax,邮件,休闲,tibco)