发我邮箱gaoht@mail.cooec.com.cn
看看
我给你看了一下
Function SendEmail(ByVal sMail As String, ByVal sSubject As String, ByVal sBody As String, sAtt As String)
Dim olApp As Object
Dim olNameSpace As Object
Dim olFolder As Object
Dim olMail As Object
Set olApp = CreateObject("Outlook.Application")
Set olNameSpace = olApp.GetNamespace("MAPI")
Set olFolder = olNameSpace.GetDefaultFolder(6)
Set olMail = olApp.CreateItem(0)
With olMail
.Subject = sSubject '邮件主题
.Recipients.Add sMail '收件人地址
.htmlbody = sBody '邮件内容
' .Attachments.Add sAtt '邮件附件
.Send
End With
End Function
涂红色的地方,Attachments 你使用的有问题,Add方法的第一个参数是文件的完整路径,你应该把函数传进来的字符串 写到一个临时Excel文件中,然后把这个文件保存,在把这个文件路径用到这个参数上 就可以了
完整的Attachments方法说明你可以进入到outlook宏编辑器 点帮助 可以查到