|
附件代码能够实现outlook群发邮件,但是无法引入签名,在代码中添加签名的代码 但是依旧无法运行,还望论坛高手多多赐教
Function GetBoiler(ByVal sFile As String) As String
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Sub sendemail00()
Dim myOlApp As Object
Dim myitem As Object
Dim i As Integer, j As Integer
Dim strg As String
Dim atts As Object
Dim mycc As Object
Dim myfile As String
Dim SigString As String
Dim Signature As String
Set myOlApp = CreateObject("Outlook.Application")
SigString = Environ("appdata") & "\Microsoft\Signatures\往来.htm" '获取签名路径
If Dir(SigString) <> "" Then '判断签名路径存在,存在则获取签名
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
With Sheets("Sheet1")
i = 2
Do While .Cells(i, 2) <> ""
Set myitem = myOlApp.CreateItem(0)
Set atts = myitem.Attachments
myitem.To = .Cells(i, 2) '收件人E-mail
myitem.cc = .Cells(i, 3) 'CC
myitem.Subject = .Cells(i, 4) '标题
myitem.Body = .Cells(i, 1) & ",你好!" & vbNewLine & vbNewLine & vbNewLine & .Cells(i, 5) '正文
myfile = Dir(ThisWorkbook.Path & "\*" & .Cells(i, 1) & "*.*")
Do Until myfile = ""
myitem.Attachments.Add ThisWorkbook.Path & "\" & myfile, 1
myfile = Dir
Loop
myitem.display '预览,如果想直接发送,把.display改为.send
i = i + 1
strg = ""
Loop
End With
Set myitem = Nothing
End Sub
|
|