|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 对帐单发送()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim cancelsend As Long
Dim i As Integer
For i = 5 To Sheets("通讯录").[A65536].End(xlUp).Row
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
'strbody = "您好!请及时查看贵公司对账单" '邮件内容
On Error Resume Next
With OutMail
.To = Sheets("通讯录").Range("C" & i).Value '邮件地址
.CC = ""
.BCC = ""
.subject = "[" & Sheets("通讯录").Cells(i, 2).Value & "]" & Sheets("通讯录").Cells(1, 2).Value '邮件主题
.Body = Sheets("通讯录").Cells(2, 2).Value ' strbody '邮件内容
'If Sheets("通讯录").Cells(i, 4).Value <> "" Then
.Attachments.Add "E:\对账单\" & Sheets("通讯录").Cells(i, 3).Value & Sheets("通讯录").Cells(i, 2).Value & ".xls" '邮件附件存放目录(附加文件)
.Attachments.Add "E:\对账单\" & Sheets("通讯录").Cells(i, 2).Value & Sheets("通讯录").Cells(i, 3).Value & ".xls" '邮件附件存放目录(附加文件)
'End If
If OutMail.Attachments.Count <> 0 Then
'cancelsend = MsgBox(" 是否忘记粘贴附件了 !" & vbNewLine & vbNewLine & " 确定要发送吗?", _
vbYesNo + vbDefaultButton2 + vbQuestion, "忘记粘贴附件提示")
' If cancelsend = vbNo Then Cancel = True
' Else:
.Send
End If
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Next i
End Sub
大侠们:我用的是上面的代码来自动发送邮件,但最近出现了问题,因为对方客户好多是QQ邮箱,好多邮件自动退回,没有发送成功。是短时间内发送大量邮件,会认识是邮件攻击或垃圾邮件,我想设置成延时发送,查了相关资料说mailitem...deferreddeliverytime 好用,但我不知道如何该句用法,请朋友帮忙,急,谢谢
|
|