我需要一些帮助来创建Excel VBA代码,该代码将从Excel中的单元格中读取一行用户名,然后通过在Outlook联系人列表中搜索用户电子邮件地址向所有这些用户发送电子邮件。
我已设法编写代码,从电子表格中显示outlook的撰写电子邮件对话框。
答案 0 :(得分:0)
您可以在邮件范围内使用表示并调用此处理程序发送电子邮件
Public Sub SendMail(MailTO As String, MailSubject As String, MailBody As String)
'http://officevb.com
Dim appOL As Object
Dim myEmail As Object
Dim TxtHello As String
Set appOL = CreateObject("Outlook.Application")
Set myEmail = appOL.CreateItem(olMailItem)
'Use hour to create a text
Select Case Hour(Time)
Case Is <= 12
TxtHello = "Good Morning," & vbNewLine
Case Is >= 12
TxtHello = "Good Afternoom," & vbNewLine
Case Is >= 18
TxtHello = "Good Night," & vbNewLine
End Select
With myEmail
.display
.Recipients.Add MailTO
.Subject = MailSubject
.Body = TxtHello & MailBody
.Send
End With
Set myEmail = Nothing
Set appOL = Nothing
End Sub
调用此子传递这些参数
sendMail“Mail@yourContact.com”,“测试”,“这是一个自动邮件”
[]的