根据日期自动从excel发送电子邮件 [英] Sending email from excel automatically based on date
问题描述
日期预定电话票据
07/06/2015 0 5无
07/07/2015 5 12无
07/08/2015 2 10无
I我正在尝试编写一个程序,比如说在7/06/2015,一个电子邮件将被生成在那个日子里安排的日程安排,通话和笔记,并自动发送。这是可能吗?
这是我认为可以是一个坚实的开始。你显然必须解决消息应该发送到哪个电子邮件地址,以及如何格式化正文和什么。
给定r的范围基于示例您提供的数据,占用A2-A4,但将其更改为任何正确的。
Option Explicit
子电子邮件()
Dim r As Range
Dim cell As Range
设置r =范围(A2:A4)
对于每个单元格r
如果cell.Value = Date Then
Dim Email_Subject,Email_Send_From,Email_Send_To,_
Email_Cc,Email_Bcc,Email_Body As String
Dim Mail_Object,Mail_Single As Variant
Email_Subject =subject
Email_Send_From =bob@bob.com
Email_Send_To =bob@bob.com
Email_Cc =bob@bob.com
Email_Bcc =bob@bob.com
Email_Body =body
错误G o调试
设置Mail_Object = CreateObject(Outlook.Application)
设置Mail_Single = Mail_Object.CreateItem(0)
使用Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
.send
结束
结束如果
下一个
退出子
调试:
如果Err.Description<> Then MsgBox Err.Description
End Sub
I have an excel sheet with dated scheduling information. I would like to send daily updates on how many calls and how many appointments have been scheduled every day. The spreadsheet looks as follows:
Date Scheduled Called Notes
07/06/2015 0 5 None
07/07/2015 5 12 None
07/08/2015 2 10 None
I am trying to write a program that, say on 7/06/2015, an email will be generated with that days scheduled, calls, and notes in the body and automatically sent. Is this possible?
Here's what I think could be a solid start. You'll obviously have to resolve what email address the message should be sent to and how to format the body and whatnot.
The range given to r was based on the sample data you provided, which occupied A2-A4, but change this to whatever is correct.
Option Explicit
Sub email()
Dim r As Range
Dim cell As Range
Set r = Range("A2:A4")
For Each cell In r
If cell.Value = Date Then
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = "subject"
Email_Send_From = "bob@bob.com"
Email_Send_To = "bob@bob.com"
Email_Cc = "bob@bob.com"
Email_Bcc = "bob@bob.com"
Email_Body = "body"
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
.send
End With
End If
Next
Exit Sub
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub
这篇关于根据日期自动从excel发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!