高分求救 手机短信定时发送问题!!!

龍月 2010-03-18 11:57:45
用的是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;//不是立即发送,采用定时发送

........省略代码


怎么实现定时发送啊。
...全文
755 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
feile922 2010-04-06
  • 打赏
  • 举报
回复
我给你顶一个,沉了可惜...
龍月 2010-04-06
  • 打赏
  • 举报
回复
解决了
feile922 2010-03-30
  • 打赏
  • 举报
回复
我给你顶一个,沉了可惜...
我不懂电脑 2010-03-18
  • 打赏
  • 举报
回复
用一个Timer定时就可以了。在OnTimer事件里写代码。
guyehanxinlei 2010-03-18
  • 打赏
  • 举报
回复
写一个服务定时定期执行上述代码即可.
whowhen21 2010-03-18
  • 打赏
  • 举报
回复
我给你顶一个,沉了可惜...
yanniu008 2010-03-18
  • 打赏
  • 举报
回复
service + 短信发送猫
龍月 2010-03-18
  • 打赏
  • 举报
回复
我理解错了
灵雨飘零 2010-03-18
  • 打赏
  • 举报
回复
用一个Timer定时就可以了。在OnTimer事件里写代码。
zuoming120 2010-03-18
  • 打赏
  • 举报
回复
我感觉楼主有点理解有误,这个定时发送就是隔多长时间发送一次,你贴出来的实例说明恕我愚钝,我没有看明白,但是我当时做这个时候是调用组件,没有你这么方便,那个定时发送还是自己写的,而且我做给别人接口也是只让他们填个数字就好了,你这样我是真的没有看懂
龍月 2010-03-18
  • 打赏
  • 举报
回复
怎么没人了?再多回答回答北!!拜托啦各位
龍月 2010-03-18
  • 打赏
  • 举报
回复
我的是 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;

 

烈火蜓蜻 2010-03-18
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 ly_longyue 的回复:]
引用 2 楼 guyehanxinlei 的回复:
写一个服务定时定期执行上述代码即可.


难道接口的自己定时发送功能不能用了???
[/Quote]


CMPP3.0可以有定时发送的功能,

这个协议里有个参数是指定哪个时间发送,你把要定时的时间填写到这个参数上,然后把短信内容发送到短信网关,短信网关会在指定的时间发出这条短信。而不需要你去做定时
龍月 2010-03-18
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 tjficcbw 的回复:]
引用 3 楼 songhtao 的回复:
用一个Timer定时就可以了。在OnTimer事件里写代码。

人家全说用定时器了,还说没人来具体解释呢,

下面的代码示例阐释了 Timer 类的功能。

C# code




using System;
using System.Threading;

class TimerExample
{
static void……
[/Quote]

我晕,我以为只要给attime赋值,并且不采用即时发送,就会自己延迟发送。
接口上是这么说的啊?
难道要我自己计时??????
tjficcbw 2010-03-18
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 songhtao 的回复:]
用一个Timer定时就可以了。在OnTimer事件里写代码。
[/Quote]
人家全说用定时器了,还说没人来具体解释呢,

下面的代码示例阐释了 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();
}
}
}



同光和尘 2010-03-18
  • 打赏
  • 举报
回复
因为这个问题貌似不会
龍月 2010-03-18
  • 打赏
  • 举报
回复
人工置顶,怎么没人来具体解释下呢???
ziwopengzhang 2010-03-18
  • 打赏
  • 举报
回复
关注一下,关注一下,顺便帮顶,顺便接分
龍月 2010-03-18
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 guyehanxinlei 的回复:]
写一个服务定时定期执行上述代码即可.
[/Quote]

难道接口的自己定时发送功能不能用了???

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧