|
Sub SendMail()
MMyNames = Array("张三@163.com", "李四@tom.com", "王五@hotmail.com") '收件人地址
MyDocuments = Array("张三.doc", "李四.doc", "王五.doc") '附件文件名,注意与收件人的一一对应关系
For DCount = 0 To UBound(Mynames) '设定循环次数,即收件人数。
MyFile = Dir("d:\bbb\" & MyDocuments(DCount)) '尝试从硬盘提取附件,逐个检测附件是否存在。
If Len(MyFile) > 0 Then '如果附件存在就进入发邮件程序。否则忽略。
Call Sendthis(MyNames(Dcount), MyDocuments(Dcount))
End If
Next Dcount
End Sub
Sub Sendthis(ByVal MyName, ByVal MyDocument As String)
Dim ItemUsageEmail As Outlook.MailItem
Set ItemUsageEmail = Application.CreateItem(olMailItem)
With ItemUsageEmail
.To = MyName '提取相应的收件人,发送邮件。
.Subject = "Report"
.Body = "This is a example"
.Attachments.Add "d:\ddd\" & MyDocument
'.Display
.Send
End With
ItemUsageEmail = Nothing
End Sub
[ 本帖最后由 roof 于 2009-3-14 13:50 编辑 ] |
|