|
此文章由 yang~_~ 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 yang~_~ 所有!转贴必须注明作者、出处和本声明,并保持内容完整
你的outlook date是excel中某一列吧,以下是提前7天通知的VBA代码,有问题就问。首先建一个邮件库到本地,最简单的做法,右键点击你的邮件库复制到本地。密码需要输入你当前ID密码,如果不想输密码,则运行VBA时需要你的Notes客户端已经打开。
Sub CheckExcel()
Dim i As Integer
i = 2
tempdate = Sheets("sheet1").Cells(i, 1).Value
While Not tempdate = ""
If tempdate - Date >= 7 Then
Call SendEmailByNotes
End If
i = i + 1
tempdate = Sheets("sheet1").Cells(i, 1).Value
Wend
End Sub
Function SendEmailByNotes()
Dim Maildb As Object
Dim MailDoc As Object
Dim Body As Object
Dim Session As Object
Dim nSend As Variant
Dim nRTItem As Object
On Error GoTo errHandle
nSend = VBA.Array("name1@xxx.com", "name2@xxx.com")
Set Session = CreateObject("Lotus.NotesSession")
Call Session.Initialize("<password>")
Set Maildb = Session.GETDATABASE("", "C:\Program Files\IBM\Lotus\Notes\data\testmail.nsf")
If Not Maildb.IsOpen = True Then Call Maildb.Open
'Create the Mail Document
Set MailDoc = Maildb.CREATEDOCUMENT
'Set subject of the mail
Call MailDoc.REPLACEITEMVALUE("Subject", "Test")
'Set the Recipient of the mail
Call MailDoc.REPLACEITEMVALUE("SendTo", nSend)
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
MailDoc.SAVEMESSAGEONSEND = True
Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
'Create and set the Body content of the mail
Set nRTItem = MailDoc.CREATERICHTEXTITEM("Body")
Call nRTItem.AddNewLine(2)
Call nRTItem.AppendText("This is a test mail")
Call MailDoc.SEND(False)
Set Maildb = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set nRTItem = Nothing
Set Session = Nothing
errHandle:
Set Maildb = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set nRTItem = Nothing
Set Session = Nothing
End Function |
评分
-
查看全部评分
|