|
本帖最后由 kangatang 于 2012-2-24 12:48 编辑
各位高手大侠:
增加一些代码,将以下模块所发送的邮件在发送后自动删除。
代码怎么写?所有代码(包括欲新增加的代码)在EXCEL VBA中实现, 不要放在OUTLOOK中。
谢谢!
=======================
Sub Main()
SendMail ***@163.com, "hello", "hello world", "***@hotmail.com, "D:\test.txt""
End Sub
Private Sub SendMail(Email_Address$, Subject$, Body$, CC_email_add$, Attachment$)
Dim objOL As Object
Dim itmNewMail As Object
Set objOL = CreateObject("Outlook.Application")
Set itmNewMail = objOL.CreateItem(olMailItem)
With itmNewMail
.Subject = Subject
.Body = Body
.to = Email_Address
.CC = CC_email_add
.Attachments.Add Attachment
End With
On Error GoTo continue
SendEmail:
itmNewMail.display
Debug.Print " "
DoEvents
DoEvents
DoEvents
SendKeys "%s", Wait:=True
DoEvents
GoTo SendEmail
continue:
Set objOL = Nothing
Set itmNewMail = Nothing
End Sub
=================
自己做了个(谢谢dsd999版主的光临和支持,以下附件也不是100%可靠)
EXCEL VBA发送后删除已发送副本.rar
(8.84 KB, 下载次数: 35)
改进版,100%可靠。采用".DeleteAfterSubmit = True"
EXCEL VBA发送后删除已发送副本.rar
(7.56 KB, 下载次数: 96)
|
评分
-
1
查看全部评分
-
|