如何在Lotus Domino中实现发送短信

import lotus.domino.*;
import java.net.*;
import java.io.*;

public class JavaAgent extends AgentBase {
  Database db = null;
  Session session = null;
  
  public void CreadSendSmsLog(String SendUser, String SendTo ,String Tel ,String Body){
  	
	//创建发送手机短信日志
	Document LogDoc = null;
	DateTime dt = null;
	try{
		dt = session.createDateTime("Today");
     	//dt.setNow();
		LogDoc = db.createDocument();
		LogDoc.replaceItemValue("form","smslog");
		LogDoc.replaceItemValue("Subject",Body);
		LogDoc.replaceItemValue("SendUser",SendUser);
		LogDoc.replaceItemValue("SendTo",SendTo);
		LogDoc.replaceItemValue("Tel",Tel);
		LogDoc.replaceItemValue("SendDate",dt);
		LogDoc.save(true,false);
		
	}catch(NotesException ne){
		ne.printStackTrace();
	}finally{
		try{
			if(null!=LogDoc)LogDoc.recycle();
			if(null!=dt)dt.recycle();
		}catch(NotesException e){
			e.printStackTrace();
		}
	}
	
  }
	
	
    public void NotesMain() {
        PrintWriter out = null;
        iSMSClient2000 objSMS = null;
	
	View viewsmslist = null;
	ViewEntryCollection vec = null;
	ViewEntry entry = null;
	Document viewdoc = null;
	Document logdoc = null;
  	AgentContext ac = null;
        try {
            session = getSession();
            ac = session.getAgentContext();
            //  Document doc = ac.getDocumentContext();
            objSMS = new iSMSClient2000();
            
            db = ac.getCurrentDatabase();
            viewsmslist = db.getView("viewsmslist");
		  vec = viewsmslist.getAllEntries();
		  
            if (objSMS.OpenSMS("127.0.0.1", 8090)) {
              	 for (int i = 1; i<=vec.getCount();i++){
              	 	try{
              	 		System.out.println(i);
              	 		entry = vec.getNthEntry(i);
              	 		viewdoc = entry.getDocument();
              	 		
              	 		String Body=viewdoc.getItemValueString("Body");
					String SendUser=viewdoc.getItemValueString("SendUser");
					String SendTo=viewdoc.getItemValueString("UserName");
					String Tel=viewdoc.getItemValueString("Tel");
              	 		
              	 		if (objSMS.SendSMS("1",Tel,Body)) {
	                        	//out.println("发送成功!");
						viewdoc.replaceItemValue("IsSent","1");
						viewdoc.save(true,false);
	                        	CreadSendSmsLog(SendTo,SendUser,Tel,Body);
	                    } else {
	                        //out.println("发送失败!");
	                        	viewdoc.replaceItemValue("IsSent","1");
						viewdoc.save(true,false);
	                        	CreadSendSmsLog(SendTo,SendUser,Tel,Body);
	                    }
              	 	}catch(NotesException ne){
         	 		  ne.printStackTrace();
              	 	}finally{
              	 		if(null!=viewdoc){viewdoc.recycle();}
              	 		if(null!=entry){entry.recycle();}              	 		
              	 	}
              	 }
             
            
            } else {
                out.println("打开服务器失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
        	try{
        	if(null!=vec)vec.recycle();
        	if(null!=viewsmslist)viewsmslist.recycle();
		if(null!=db)db.recycle();
		if(null!=ac)ac.recycle();
		if(null!=session)session.recycle();
        	//out.close();
        	}catch(NotesException nne){
        		nne.printStackTrace();
        	}
        	objSMS.CloseSMS();
		System.gc();
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值