|
楼主 |
发表于 2015-1-24 15:19
|
显示全部楼层
闻启学 发表于 2015-1-23 23:09
txt 文件是不能存放图片的 不用检查
你试一试提取html 文件吧 估计都不行
试了,果然!就是图片显示不出来。
Sub send()
Dim strbody As String, strsubject As String
Dim strmail As String, strcc As String, strbcc As String
Dim stratt1 As String, stratt2 As String, stratt3 As String
With ActiveSheet
strmail = .Range("F4")
strcc = .Range("f5")
strbcc = .Range("f6")
strsubject = .Range("F7")
strbody = .Range("F8")
stratt1 = .Range("f9")
stratt2 = .Range("f10")
stratt3 = .Range("f11")
End With
sendemail strmail, strcc, strbcc, strsubject, strbody, stratt1, stratt2, stratt3
MsgBox "complete", vbInformation + vbOKOnly, "note"
End Sub
Function sendemail(ByVal smail As String, ByVal scc As String, ByVal sbcc As String, ByVal ssubject As String, ByVal sbody As String, ByVal sAtt1 As String, ByVal sAtt2 As String, ByVal sAtt3 As String)
On Error Resume Next
Dim olapp As Object
Dim olnamespace As Object
Dim olfolder As Object
Dim olmail As Object
Dim signature As String
Set olapp = CreateObject("outlook.application")
Set olnamespace = olapp.getnamespace("mapi")
Set olfolder = olnamespace.getdefaultfolder(6)
Set olmail = olapp.createitem(0)
Dim mysign As String
mysign = "C:\Users\Ray\AppData\Roaming\Microsoft\Signatures\test.htm"
With olmail
.Subject = ssubject
.to = smail
.cc = scc
.bcc = sbcc
mysign = getboiler(mysign)
.BodyFormat = olFormatHTML
.HTMLBody = sbody & "<br />" & mysign
.attachments.Add sAtt1
.attachments.Add sAtt2
.attachments.Add sAtt3
.send
End With
End Function
Function getboiler(ByVal sfile As String) As String
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("scripting.filesystemobject")
If fso.fileexists(sfile) Then
Set ts = fso.getfile(sfile).openastextstream(1, -2)
getboiler = ts.readall
ts.Close
Else
getboiler = ""
End If
End Function
如果把 ON ERROR RESUME NEXT去掉。.BodyFormat = olFormatHTML就被标黄了,
现在不知道是什么问题。应该可以发有图片的签名吧?VBA这么强大,不应该不能啊? |
|