用的是EMPP 移动接口
........省略代码
        
EMPPLib.ShortMessage shortMsg=new EMPPLib.ShortMessageClass();                
shortMsg.srcID=accountId;                
shortMsg.ServiceID=serviceId;                
shortMsg.needStatus=true;                
EMPPLib.Mobiles mobs=new EMPPLib.MobilesClass();        mobs.Add("xxxxxx");//手机号
                shortMsg.DestMobiles = mobs;
                System.DateTime dt = System.DateTime.Now;  //获取时间
                shortMsg.atTime = dt;//给他赋值。没有用,调试时 一直为NULL
                shortMsg.SendNow = false;//不是立即发送,采用定时发送........省略代码
        怎么实现定时发送啊。

解决方案 »

  1.   

    用一个Timer定时就可以了。在OnTimer事件里写代码。
      

  2.   

    人家全说用定时器了,还说没人来具体解释呢,
     
    下面的代码示例阐释了 Timer 类的功能。
    using System;
    using System.Threading;class TimerExample
    {
        static void Main()
        {
            AutoResetEvent autoEvent     = new AutoResetEvent(false);
            StatusChecker  statusChecker = new StatusChecker(10);        // Create the delegate that invokes methods for the timer.
            TimerCallback timerDelegate = 
                new TimerCallback(statusChecker.CheckStatus);        // Create a timer that signals the delegate to invoke 
            // CheckStatus after one second, and every 1/4 second 
            // thereafter.
            Console.WriteLine("{0} Creating timer.\n", 
                DateTime.Now.ToString("h:mm:ss.fff"));
            Timer stateTimer = 
                    new Timer(timerDelegate, autoEvent, 1000, 250);        // When autoEvent signals, change the period to every 
            // 1/2 second.
            autoEvent.WaitOne(5000, false);
            stateTimer.Change(0, 500);
            Console.WriteLine("\nChanging period.\n");        // When autoEvent signals the second time, dispose of 
            // the timer.
            autoEvent.WaitOne(5000, false);
            stateTimer.Dispose();
            Console.WriteLine("\nDestroying timer.");
        }
    }class StatusChecker
    {
        int invokeCount, maxCount;    public StatusChecker(int count)
        {
            invokeCount  = 0;
            maxCount = count;
        }    // This method is called by the timer delegate.
        public void CheckStatus(Object stateInfo)
        {
            AutoResetEvent autoEvent = (AutoResetEvent)stateInfo;
            Console.WriteLine("{0} Checking status {1,2}.", 
                DateTime.Now.ToString("h:mm:ss.fff"), 
                (++invokeCount).ToString());        if(invokeCount == maxCount)
            {
                // Reset the counter and signal Main.
                invokeCount  = 0;
                autoEvent.Set();
            }
        }
    }
      

  3.   


    我晕,我以为只要给attime赋值,并且不采用即时发送,就会自己延迟发送。
    接口上是这么说的啊?
    难道要我自己计时??????
      

  4.   

    CMPP3.0可以有定时发送的功能,这个协议里有个参数是指定哪个时间发送,你把要定时的时间填写到这个参数上,然后把短信内容发送到短信网关,短信网关会在指定的时间发出这条短信。而不需要你去做定时 
      

  5.   

    我的是 EMPP.2.0.0 接口里面也有说定时发送ShortMessage 对象用于实现对短信协议结构的设置,提取操作。主要有如下属性: atTime 设置,获取定时发送时间。 
    needStatus 获取,设置是否需要状态报告标志位。 
    DestMobiles 获取,设置目的手机号。 
    SendNow 获取,设置是否立即发送标志。 
    srcID 获取,设置发送者手机号。 
    content 获取,设置短信内容。 
    ServiceID 设置,获取服务代码。 -----------------------
    SendNow  属性:
    获取,设置是否立即发送短信标志说明是否立即发送。#define VARIANT_TRUE ((VARIANT_BOOL)0xffff)
    #define VARIANT_FALSE ((VARIANT_BOOL)0)VARIANT_FALSE :定时发送;
    VARIANT_TRUE:立即发送。--------------------------------------
    atTime 属性:
    定时发送时间说明时间可以读写。格式“YYMMDDhhmmsstnnp ” YY 年份的最后2 位 (00-99),如果YY大于90则解释为19YY,否则解释为20YY。MM 月份(01-12),DD 日 (01-31),Hh 小时 (00-23),Mm 分 (00-59),Ss 秒 (00-59),t 十分之一秒 (0-9),nn 为本地时间与UTC (Universal Time Constant) 时间超前或落后的差距(00-48)单位为四分之一小时,‘+’时间超前于UTC time.‘-’ 时间落后于 UTC time.例:“020610233429508-”表示2002年6月10日23点34分29.5秒,比UTC time落后2小时组件已经将时区设定为北京时间。示例://写入:"040929221500032+"组件已经将时区设定为北京时间。//时间为:东八区时间(北京时间)2004年,9月29日22时15分0秒COleDateTime dtAtTime( 2004, 9, 29, 22, 15, 0 ) ;shortMsg->atTime = _variant_t(DATE(dtAtTime), VT_DATE);//读取:dtAtTime = (COleDateTime)AtTime; 
      

  6.   

    用一个Timer定时就可以了。在OnTimer事件里写代码。