第一种方法
Sub SendWithLotus()
Dim noSession As Object,noDatabase As Object
Dim noDocument As Object,noAttachment As Object
Dim Fi leSelf As String
Dimi As Long
Co nst EM BED_ATTACHMENT= 1454
Const stSubject As String="For Lotus VBA Programming Test only"
D i m stMsg As Stri ng
Fi leSelf=ThisWorkbook Path+"\"+ThisWorkbook NamestMsg="Bst&Rgds"&vbCrLf&_
Application UserName&vbCrLf&_
"**********************
"(This's an automated e-mai l notification,please do not reply this message)"
DimvaRecipient As VariantvaRecipient=VBA Array("huangfeng8211@163 com")
'Insert Lotus Notes COM object
Set noSession=CreateObject("Notes NotesSession")
Set noDatabase=noSession GETDATABASE("","D:\notes\data\mai l3\tonyhf nsf")
If noDatabase IsOpen= False Then noDatabase OPENMAIL
Set noDocument=noDatabase CREATEDOCUMENT
Set noAttachment= noDocument CREATERICHTEXTITEM("Body")noAttachment EMBED OBJECT EMBED_ATTACHMENT,"" ,Fi leSelf
With noDocument
Fo rm="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 fi le be sent" ,vbInformation
EndSub
第二种方法
Sub SendWithLotus()
Dim noSession As Object,noDatabase As Object
Dim noDocument As Object,noAttachment As Object
Dim vaFi les As Variant
Dimi As Long
Co nst EM BED_ATTACHMENT= 1454
Const stSubject As String="For Lotus VBA Programming Test only"
Const stMsg As Stri ng="This fi le is for you!j ust for reference"&vbCrLf&"I am StanleyPan"
DimvaRecipient As VariantvaReci pi ent=VBA Array("stan leypan2000@hotmai l com" ,"stanley pan@Iso laAg com")vaFi les = ApplicationGetOpenFi lename(Fi leFi lter:="Excel Fi ler (*xls),*xls" , Title:="Attach fi les for outgoing E_Mai l" ,MultiSelect:=True)
If Not IsArray(vaFi les)Then Exit Sub
'Insert Lotus Notes COM object
Set noSession=CreateObject("Notes NotesSession")
Set noDatabase=noSession GETDATABASE("","D:\notes\data\mai l3\tonyhf nsf")
If noDatabase IsOpen= False Then noDatabase OPENMAIL
Set noDocument=noDatabase CREATEDOCUMENT
Set noAttachment= noDocument CREATERICHTEXTITEM("Body")
With noAttachment
For i =1 To UBound(vaFi les)
EMBED OBJECT EMBED_ATTACHMENT,"",vaFi les(i)
Next i
End With
With noDocument
Fo rm="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"Thisfi le is send OK" ,vbInformation
EndSub
a,返回当前数据库的名称
结果
b,返回当前数据库的文件名
c,返回当前数据库的文件路径
Sub aaaaaa()
Dimno AsObject
Dim db As Object
Dim doc As Object
Dim fields As Object
Dim nofields As Object
Dimatt As Variantatt=ApplicationGetOpenFi lename(Fi leFi lter:="Excel Fi ler(*xls),*xls" ,_
Title:="Attach fi les for outgoing E_Mai l" ,MultiSelect:=True) '添加附件
Set no=CreateObj ect("notes notessession")'建立和邮件的连接
Set db=no CURRENTDATABASE'建立和邮件数据库的连接
Set doc=db CREATEDOCUMENT'创建一个新的邮件
Set fields=doc CREATERICHTEXTITEM("body") '设置新邮件的正文附件对象With fields'设置邮件的正文和附件
APPENDTEXT" this e-mai l is generated by an automated processjust for a test"ADDNEWLINE 1 '增加第一行
APPENDTEXT" please do not reply"
ADDNEWLINE 2 '增加第二行
For i = 1 To UBound(att) '添加附件
E MB ED OB J E CT 1454,"" ,att(i)
Next i
EndWith
With doc '设置新邮件的除正文和附件外的其他信息form= "Memo" '新邮件sendto=VBA Array("huangfeng8211@163 com" ,"tonyhf@cn i bm com") '发送给Subject= "this mai l isjust for testing" '主题
SAVEMESSAGEONSEND=True'是否保存发送的邮件到发件箱postdate=DateAdd("d" ,1,Date) '发送日期等于当天
SEND0'发送
EndWith
MsgBox"successfully sent out the mai l!"
Set no=Nothing'释放内存
Set db=Nothing
Set doc=Nothing
Set fields=Nothing
EndSub
在添加附件的时候如果只是想将当前的活动工作薄作为附件的话如下
注意一下,如果是1452的话,效果如下,
会出现一个提示,询问文档包含外部对象链接,是否要更新链接,如果确定的话,效果如下,会将EX CEL文件中的内容以图片形式打开,同时文件是只读格式的,
如果是1453,效果如下,
不会有提示,但是文件为只读,
如果为1454,则为正常的EX CEL文件格式,
3,提取邮件的一些信息
以上的发件人发送时间主题等信息还可以如下表示
运行结果
a,收件箱等邮箱本身就存在的
b,如果是自己创建的文件夹及子文件夹
比如在我的邮箱中有自定义的文件夹 fo lders,如果要想获取其下面的子文件夹之一的相关资料则应如下书写4,用上面的方法提取出来的发件人是有公司名称的anotes CREATENAME(adocumentGETITEMVALUE("from")(0))ABBREVIATED
如果不使用abbreviated,则结果为
如果想要输出的发件人只有名字没有公司名的话可以做如下更改
结果为
排版之后的效果如下所示
以上代码是将发件箱中的附件保存到D盘的新建文件夹
imidc对日本独立服务器在搞特别促销,原价159美元的机器现在只需要88美元,而且给13个独立IPv4,30Mbps直连带宽,不限制流量。注意,本次促销只有一个链接,有2个不同的优惠码,你用不同的优惠码就对应着不同的配置,价格也不一样。88美元的机器,下单后默认不管就给512G SSD,要指定用HDD那就发工单,如果需要多加一个/28(13个)IPv4,每个月32美元...官方网站:https:...
pacificrack发布了7月最新vps优惠,新款促销便宜vps采用的是魔方管理,也就是PR-M系列。提一下有意思的是这次支持Windows server 2003、2008R2、2012R2、2016、2019、Windows 7、Windows 10,当然啦,常规Linux系统是必不可少的!1Gbps带宽、KVM虚拟、纯SSD raid10、自家QN机房洛杉矶数据中心...支持PayPal、...
柚子互联官网商家介绍柚子互联(www.19vps.cn)本次给大家带来了盛夏促销活动,本次推出的活动是湖北十堰高防产品,这次老板也人狠话不多丢了一个6.5折优惠券而且还是续费同价,稳撸。喜欢的朋友可以看看下面的活动详情介绍,自从站长这么久以来柚子互联从19年开始算是老商家了。六五折优惠码:6kfUGl07活动截止时间:2021年9月30日客服QQ:207781983本次仅推荐部分套餐,更多套餐可进...