將某資料庫的ACL資訊寫入檔案將其作為附件寄出

withwangzhen發表於2011-06-08

Dim db As New notesdatabase(“”,”XXX.nsf”)
Dim acl As notesAcl,session As New notesSession
Dim entry As notesACLEntry,myLevel As String,t1 As Integer
Dim myFile As String
Set acl=db.acl
‘將Acl條目資訊寫入一個臨時檔案
myFile=”c:\myACL.txt”
Open myFile For Output As #1
Set entry=acl.getfirstEntry
Do Until entry Is Nothing
t1=entry.level
If t1=6 Then myLevel=”Manager”
If t1=5 Then myLevel=”Designer”
If t1=4 Then myLevel=”Editor”
If t1=3 Then myLevel=”Author”
If t1=2 Then myLevel=”Reader”
If t1=1 Then myLevel=”Depositor”
If t1=0 Then myLevel=”No Access”
Print #1,entry.name;Tab(50);mylevel
‘得到該條目的所以角色
Forall y In entry.roles
If y=”" Then
Else
Print #1,”…role:”&y
End If
End Forall
Set entry=acl.getNextEntry(entry)
Print #1,”"
Print #1,”———-”
Loop
Close #1
Print “file writtento”&myFile

‘建立郵件文件,將包含Acl資訊的臨時文件作為附件寄出
Set doc=New notesDocument(db)
Set rtitem=New notesRichTextItem(doc,”body”)
Dim recipients(1 To 3) As String
recipients(1)=session.commonUserName
Messagebox session.commonuserName
messageSubject=”存取控制列表”
MessageBody=”控制列表內容,在附件上單擊滑鼠右鍵,並選擇”+Chr$(34)+”啟動”+Chr$(34)+”檢視這個檔案”
doc.body=MessageBody
Set bject=rtitem.EmbedObject(EMBED_ATTACHMENT,”",myFile,”Attachment1″)
‘doc.Form=”Main Topic”
doc.subject=messageSubject

Call doc.send(False,recipients)
‘Call doc.save(True,True)
Print “郵件已寄出”
Messagebox “郵件已寄出”,0,”Email Sent!”
Kill MyFile
Print “臨時檔案:”+MyFile+” 已被刪除。”

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24998103/viewspace-697350/,如需轉載,請註明出處,否則將追究法律責任。

相關文章