ExcelTip.Net留存知识帖 ---【注:附件之前被网盘供应商清空后,现已修复-现已修复-现已修复为本地下载!】
现在位置:首页 > E问E答 > Excel VBA > 如何用VBA发送NOTES邮件?

如何用VBA发送NOTES邮件?

作者:绿色风 分类: 时间:2022-08-17 浏览:75
楼主
omnw
Q:如何用VBA发送NOTES邮件?
A:例如如下代码,可以将指定的附件发送给多个收件人。
FileSelf参数为附件的完整路径。
vaRecipient参数为收件人列表。
  1. Sub SendWithLotus(FileSelf As String, vaRecipient As Variant)
  2.     Dim noSession As Object, noDatabase As Object
  3.     Dim noDocument As Object, noAttachment As Object
  4.     Dim i As Long
  5.     Dim stSubject As String
  6.     Dim stMsg As String
  7.     Const EMBED_ATTACHMENT = 1454
  8.     stSubject = FileSelf
  9.     stMsg = "Bst & Rgds" & vbCrLf & Application.UserName & vbCrLf & vbCrLf & "**************************************************************************" & vbCrLf & "(This's an automated e-mail notification, please do not reply this message.)"
  10.     Set noSession = CreateObject("Notes.NotesSession") 'Insert Lotus Notes COM object.
  11.     Set noDatabase = noSession.GETDATABASE("", "")
  12.     If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
  13.     Set noDocument = noDatabase.CreateDocument
  14.     Set noAttachment = noDocument.CreateRichTextItem("Body")
  15.     noAttachment.EmbedObject EMBED_ATTACHMENT, "", FileSelf
  16.     With noDocument
  17.         .Form = "Memo"
  18.         .SendTo = vaRecipient
  19.         .Subject = stSubject
  20.         .Body = stMsg
  21.         .SaveMessageOnSend = True
  22.         .PostedDate = Now()
  23.         .Send 0, vaRecipient
  24.     End With
  25.     Set noDocument = Nothing
  26.     Set noDatabase = Nothing
  27.     Set noSession = Nothing
  28.     AppActivate "Microsoft Excel"
  29. End Sub

使用方法:
  1. Sub 发送NOTES邮件()
  2.     SendWithLotus ThisWorkbook.FullName, VBA.Array("min yu/Accounting/HuaAn@HuaAn", "junhu li/Register Dept/HuaAn")
  3. End Sub

NOTES.rar
2楼
卖火柴的帅哥
附件运行时提示错误

免责声明

有感于原ExcelTip.Net留存知识的价值及部分知识具有的时间限定性因素, 经与ExcelTip.Net站长Apolloh商议并征得其同意, 现将原属ExcelTip.Net的知识帖采集资料于本站点进行展示, 供有需要的人士查询使用,也慰缅曾经的论坛时代。 所示各个帖子的原作者如对版权有异议, 可与本人沟通提出,或于本站点留言,我们会尽快处理。 在此,感谢ExcelTip.Net站长Apolloh的支持,感谢本站点所有人**绿色风(QQ:79664738)**的支持与奉献,特此鸣谢!
------本人网名**KevinChengCW(QQ:1210618015)**原ExcelTip.Net总版主之一

评论列表
sitemap