我无法使用任务调度,有其他选择吗?
我的 IT 办公室明确告诉我,由于我的 SQLServer 数据库位于共享 SQL Server 中,因此它们无法通过服务器调度任务服务运行任何可执行文件。该可执行文件将每天查询我的数据库,更新其中的数据并发送电子邮件。首先,这是真的吗?其次,我是否有其他选择,例如使用 .net 计时器类?我将不胜感激你的建议。非常感谢。
更新: 这是我用来发送电子邮件的代码。如果我的网站页面中有它,它就可以工作。如果我在可执行文件中运行它,我会收到错误“发送电子邮件失败”,我认为这是因为他们不允许我这样做?
Dim message As MailMessage = New MailMessage()
message.From = New MailAddress("[email protected]")
message.To.Add(New MailAddress("[email protected]"))
message.Subject = "My subject"
message.Body = "My content"
Dim smtp As SmtpClient = New SmtpClient("myserver")
smtp.Send(message)
I've been definitely told by my IT office that as my SQLServer database is in a shared SQL Server they can't run any executables via the server scheduling task service . The executable would query my database on a daily basis, update data in it and send an email. First, is this true? And secondly, do I have an alternative using .net timer classes, for example? I would appreciate your advice. Many thanks.
UPDATE:
This is the code I use to send emails. If I have it in a page of my site, it works. If I run it in a executable I get an error "Failure sending email" which I assume is because they don't let me?
Dim message As MailMessage = New MailMessage()
message.From = New MailAddress("[email protected]")
message.To.Add(New MailAddress("[email protected]"))
message.Subject = "My subject"
message.Body = "My content"
Dim smtp As SmtpClient = New SmtpClient("myserver")
smtp.Send(message)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么你认为你需要在数据库服务器上运行这些东西。您的数据库肯定可以通过网络访问,是吗?
如果是这样,为什么不设置您自己的服务器来运行查询和更新。
如果您说他们不允许您在任何地方运行访问数据库的计划任务,那么任何其他自动化解决方案都会遇到同样的问题。
根据您的更新,您可能不允许从另一个盒子连接到 SMTP 服务器(假设您的
myserver
值首先是正确的)。您必须说服该邮箱的管理员允许您访问邮件服务器,或者找到另一个 SMTP 服务器来发送邮件。在企业环境中,这可能比听起来更容易。周围应该至少有一个可靠的 SMTP 服务器,您只需要找到它即可。或者,您可能必须在自己的服务器上安装邮件客户端并使用它来发送邮件。
Why do you think you need to run these things on the database server. Your database is surely available across the network, yes?
If so, why not set up your own server box to run the queries and updates.
If you're saying that they're not going to allow you to run a scheduled task anywhere that will access the database, then any other automated solution will have the same problem.
As per your update, you are likely not permitted to connect to the SMTP server from another box (assuming your
myserver
value is correct in the first place). You will either have to convince the administrators of that box to allow you to access the mail server, or find another SMTP server for sending the mail.In a corporate environment, that's probably easier than it sounds. There should be at least one kosher SMTP server floating around, you just need to find it. Alternatively, you may have to install a mail client on your own server box and use that for sending mail.