简体   繁体   English

范围自动发送电子邮件正文

[英]Range auto send in email body

Is there any code to send a range in an email body if a certain time in a range is exceeded. 如果超出了范围内的某个时间,是否有任何代码可以在电子邮件正文中发送范围。 This should be automated and not a button. 这应该是自动化的,而不是一个按钮。

In order to get the email-sending sub to run at a set time every day, the easiest thing to do is to use the OnTime -method . 为了使电子邮件发送子程序每天在指定的时间运行,最简单的方法是使用OnTime方法 In your case, you would put something like this in the ThisWorkbook -module: 对于您的情况,您可以在ThisWorkbook -module中放置以下内容:

Private Sub Workbook_Open()
  Call new_timer
End Sub

and something like this in a standard module: 在标准模块中是这样的:

Sub email_sending_macro
  <your code to send the email>
  Application.Wait(Now + TimeValue("0:00:01"))
  Call new_timer
End Sub

Sub new_timer
  Application.OnTime TimeValue("16:00:00"), "email_sending_macro"
End Sub

This should set your code to run at 4 o'clock every day. 这应该将您的代码设置为每天4点运行。 The Application.Wait is there just in case the macro takes less than a second to run, you do not want it to send more than one email, do you? Application.Wait是为了防止宏运行少于一秒钟的时间,您不希望它发送多个电子邮件,对吗? :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM