|
用excel 的vba发送邮件(outlook)能成功,但是邮箱本来设置好的签名档没有被引用,求大神指点!
希望能用outlook设置好的签名发送,而不是在VBA里写上签名内容,这样比较麻烦!
Sub SendTest()
SendMail "18231***@qq.com", "", "helloqm", _
"test auto send email", "C:\Users\wfj\Desktop\test.txt"
End Sub
Public Sub SendMail(strTo As String, strCC As String, strSubject _
As String, strBody As String, Optional strAttach As String)
Dim otlk As Outlook.Application
Dim mailitem As Outlook.mailitem
' On Error GoTo errHandle
Set otlk = New Outlook.Application
Set mailitem = otlk.CreateItem(olMailItem)
With mailitem
.To = strTo
.CC = strCC
.Importance = olImportanceHigh
.Subject = strSubject
.Body = strBody
.Importance = olImportanceNormal '重要级别
If Len(strAttach) <> 0 Then .Attachments.Add strAttach
.Send
End With
''''' '下一段代码不注释邮件发送成功,但会报错:该项目已经被移动或删除
' Do Until mailitem.Sent = True
' DoEvents
' Loop
''''''''下一段代码不注释,会让outlook闪退
'errHandle:
' otlk.Quit
' Set otlk = Nothing
End Sub
|
|