Excel 更新通知 - Lotus Notes
Excel update notification - Lotus Notes
我对这一切都很陌生,但我遇到了以下问题。我有一个在我公司服务器上共享的 Excel 工作表,我想向不同的用户发送一封自动电子邮件,通知该文件已更新。我们用的是莲花笔记,可以吗?
我尝试了以下代码,但没有用
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = "Hello, Tvoloria! - the workbook was saved by " & Environ("USERNAME") & " at " & Format(Now(), "ddd dd mmm yy hh:mm")
.Item.To = "asd@asd.com"
.Item.Subject = "Workbook Saved!"
.Item.display
'.Item.send
End With
End Sub
您可以使用类似的方式发送电子邮件
Sub test()
Subject = "Workbook Saved!"
body = "Hello, Tvoloria! - the workbook was saved by " & Environ("USERNAME") & " at " & Format(Now(), "ddd dd mmm yy hh:mm")
Recipient = "you@xx.com"
CopyTo = "you@xx.com"
Set Session = CreateObject("Notes.NotesSession")
Set Database = Session.GETDATABASE("", "")
If Database.IsOpen = False Then Database.OPENMAIL
Set Document = Database.CreateDocument
With Document
.SendTo = Recipient
.CopyTo = CopyTo
.Subject = Subject
.body = body
.SaveMessageOnSend = True
.PostedDate = Now()
.Send 0, Recipient
End With
Set Document = Nothing
Set Database = Nothing
Set Session = Nothing
End Sub
要使用 Lotus Notes 发送邮件,您需要使用 Lotus Notes 类,而不是您找到的某些 Microsoft 东西 "somewhere out there"。
如果安装了 Notes 客户端,您可以使用 OLE:
Dim ses as Object
Dim db as Object
Dim memo as Object
Set ses = CreateObject( "Notes.NotesSession" ) '- NotesSession is the root for every action over OLE
'- create an empty database object
Set db = ses.GetDatabase( "" , "" )
'- open users mailfile
Call db.OpenMail
'- Create a new Mail
Set memo = db.CreateDocument()
'- Fill all information
With memo
.Form = "Memo"
.SendTo = "asd@asd.com"
.Subject = "Workbook Saved!"
.Body = "Hello, Tvoloria! - the workbook was saved by " & Environ("USERNAME") & " at " & Format(Now(), "ddd dd mmm yy hh:mm")
.Send( False )
这段代码只是为了演示这个想法,它没有经过测试,可能会抛出一些错误。它需要安装并启动 Lotus Notes 客户端。
我对这一切都很陌生,但我遇到了以下问题。我有一个在我公司服务器上共享的 Excel 工作表,我想向不同的用户发送一封自动电子邮件,通知该文件已更新。我们用的是莲花笔记,可以吗?
我尝试了以下代码,但没有用
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = "Hello, Tvoloria! - the workbook was saved by " & Environ("USERNAME") & " at " & Format(Now(), "ddd dd mmm yy hh:mm")
.Item.To = "asd@asd.com"
.Item.Subject = "Workbook Saved!"
.Item.display
'.Item.send
End With
End Sub
您可以使用类似的方式发送电子邮件
Sub test()
Subject = "Workbook Saved!"
body = "Hello, Tvoloria! - the workbook was saved by " & Environ("USERNAME") & " at " & Format(Now(), "ddd dd mmm yy hh:mm")
Recipient = "you@xx.com"
CopyTo = "you@xx.com"
Set Session = CreateObject("Notes.NotesSession")
Set Database = Session.GETDATABASE("", "")
If Database.IsOpen = False Then Database.OPENMAIL
Set Document = Database.CreateDocument
With Document
.SendTo = Recipient
.CopyTo = CopyTo
.Subject = Subject
.body = body
.SaveMessageOnSend = True
.PostedDate = Now()
.Send 0, Recipient
End With
Set Document = Nothing
Set Database = Nothing
Set Session = Nothing
End Sub
要使用 Lotus Notes 发送邮件,您需要使用 Lotus Notes 类,而不是您找到的某些 Microsoft 东西 "somewhere out there"。
如果安装了 Notes 客户端,您可以使用 OLE:
Dim ses as Object
Dim db as Object
Dim memo as Object
Set ses = CreateObject( "Notes.NotesSession" ) '- NotesSession is the root for every action over OLE
'- create an empty database object
Set db = ses.GetDatabase( "" , "" )
'- open users mailfile
Call db.OpenMail
'- Create a new Mail
Set memo = db.CreateDocument()
'- Fill all information
With memo
.Form = "Memo"
.SendTo = "asd@asd.com"
.Subject = "Workbook Saved!"
.Body = "Hello, Tvoloria! - the workbook was saved by " & Environ("USERNAME") & " at " & Format(Now(), "ddd dd mmm yy hh:mm")
.Send( False )
这段代码只是为了演示这个想法,它没有经过测试,可能会抛出一些错误。它需要安装并启动 Lotus Notes 客户端。