用vba操纵lotus notes发邮件

上传人:小** 文档编号:95348256 上传时间:2019-08-17 格式:DOC 页数:68 大小:3.21MB
返回 下载 相关 举报
用vba操纵lotus notes发邮件_第1页
第1页 / 共68页
用vba操纵lotus notes发邮件_第2页
第2页 / 共68页
用vba操纵lotus notes发邮件_第3页
第3页 / 共68页
用vba操纵lotus notes发邮件_第4页
第4页 / 共68页
用vba操纵lotus notes发邮件_第5页
第5页 / 共68页
点击查看更多>>
资源描述

《用vba操纵lotus notes发邮件》由会员分享,可在线阅读,更多相关《用vba操纵lotus notes发邮件(68页珍藏版)》请在金锄头文库上搜索。

1、287 , 用lotus notes发送邮件,第一种方法,Sub SendWithLotus()Dim noSession As Object, noDatabase As ObjectDim noDocument As Object, noAttachment As ObjectDim FileSelf As StringDim i As LongConst EMBED_ATTACHMENT = 1454Const stSubject As String = For Lotus VBA Programming Test onlyDim stMsg As StringFileSelf = Th

2、isWorkbook.Path + + ThisWorkbook.NamestMsg = Bst & Rgds & vbCrLf & _ Application.UserName & vbCrLf & _ vbCrLf & _ * & vbCrLf & _ (Thiss an automated e-mail notification, please do not reply this message.)Dim vaRecipient As Variant vaRecipient = VBA.Array() Insert Lotus Notes COM object. Set noSessio

3、n = CreateObject(Notes.NotesSession) Set noDatabase = noSession.GETDATABASE(, D:notesdatamail3tonyhf.nsf) If noDatabase.IsOpen = False Then noDatabase.OPENMAIL Set noDocument = noDatabase.CREATEDOCUMENT Set noAttachment = noDocument.CREATERICHTEXTITEM(Body) noAttachment.EMBEDOBJECT EMBED_ATTACHMENT,

4、 , FileSelf With noDocument .Form = Memo .SendTo = vaRecipient .Subject = stSubject .Body = stMsg .SAVEMESSAGEONSEND = True .PostedDate = Now() .SEND 0, vaRecipient End With Set noDocument = Nothing Set noDatabase = Nothing Set noSession = Nothing AppActivate Microsoft Excel MsgBox This file be sent

5、, vbInformationEnd Sub第二种方法Sub SendWithLotus()Dim noSession As Object, noDatabase As ObjectDim noDocument As Object, noAttachment As ObjectDim vaFiles As VariantDim i As LongConst EMBED_ATTACHMENT = 1454Const stSubject As String = For Lotus VBA Programming Test onlyConst stMsg As String = This file

6、is for you! just for reference & vbCrLf & I am StanleyPanDim vaRecipient As Variant vaRecipient = VBA.Array(, stanley.panIsolaA) vaFiles = Application.GetOpenFilename(FileFilter:=Excel Filer (*.xls),*.xls, Title:=Attach files for outgoing E_Mail, MultiSelect:=True) If Not IsArray(vaFiles) Then Exit

7、Sub Insert Lotus Notes COM object. Set noSession = CreateObject(Notes.NotesSession) Set noDatabase = noSession.GETDATABASE(, D:notesdatamail3tonyhf.nsf) If noDatabase.IsOpen = False Then noDatabase.OPENMAIL Set noDocument = noDatabase.CREATEDOCUMENT Set noAttachment = noDocument.CREATERICHTEXTITEM(B

8、ody) With noAttachment For i = 1 To UBound(vaFiles) .EMBEDOBJECT EMBED_ATTACHMENT, , vaFiles(i) Next i End With With noDocument .Form = Memo .SendTo = vaRecipient .Subject = stSubject .Body = stMsg .SAVEMESSAGEONSEND = True .PostedDate = Now() .SEND 0, vaRecipient End With Set noDocument = Nothing S

9、et noDatabase = Nothing Set noSession = Nothing AppActivate Microsoft Excel MsgBox This file is send OK, vbInformationEnd Sub1, 返回当前数据库的信息,a, 返回当前数据库的名称,结果,b, 返回当前数据库的文件名,c, 返回当前数据库的文件路径,2,发送邮件的一些设置,Sub aaaaaa()Dim no As ObjectDim db As ObjectDim doc As ObjectDim fields As ObjectDim nofields As Obje

10、ctDim att As Variantatt = Application.GetOpenFilename(FileFilter:=Excel Filer (*.xls),*.xls, _Title:=Attach files for outgoing E_Mail, MultiSelect:=True) 添加附件Set no = CreateObject(notes.notessession) 建立和邮件的连接Set db = no.CURRENTDATABASE 建立和邮件数据库的连接Set doc = db.CREATEDOCUMENT 创建一个新的邮件Set fields = doc.

11、CREATERICHTEXTITEM(body) 设置新邮件的正文(附件)对象 With fields 设置邮件的正文和附件 .APPENDTEXT this e-mail is generated by an automated process just for a test .ADDNEWLINE 1 增加第一行 .APPENDTEXT please do not reply. .ADDNEWLINE 2 增加第二行 For i = 1 To UBound(att) 添加附件 .EMBEDOBJECT 1454, , att(i) Next i End WithWith doc 设置新邮件

12、的除正文和附件外的其他信息 .form = Memo 新邮件 .sendto = VBA.Array(, ) 发送给 .Subject = this mail is just for testing 主题 .SAVEMESSAGEONSEND = True 是否保存发送的邮件到发件箱 .postdate = DateAdd(d, 1, Date) 发送日期等于当天 .SEND 0 发送 End WithMsgBox successfully sent out the mail!Set no = Nothing 释放内存Set db = NothingSet doc = NothingSet f

13、ields = NothingEnd Sub在添加附件的时候,如果只是想将当前的活动工作薄作为附件的话,如下,注意一下, 如果是1452的话, 效果如下, 会出现一个提示, 询问文档包含外部对象链接, 是否要更新链接, 如果确定的话, 效果如下, 会将EXCEL文件中的内容以图片形式打开, 同时文件是只读格式的, 如果是1453, 效果如下, 不会有提示, 但是文件为只读, 如果为1454, 则为正常的EXCEL文件格式, 3, 提取邮件的一些信息,以上的发件人,发送时间,主题等信息还可以如下表示,运行结果,4,指定是在收件箱,发件箱或其他自定义的文件夹,a, 收件箱等邮箱本身就存在的,b, 如果是自己创建的文件夹及子文件夹,比如在我的邮箱中有自定义的文件夹,folders, 如果要想获取其下面的子文件夹之一的相关资料,则应如下书写,4, 用上面的方

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号