Ole*_*røm 5 email excel vba excel-vba outlook-vba
我使用此代码从Excel发送电子邮件:
Sub Mail_workbook_Outlook_1()
'Working in Excel 2000-2013
'This example send the last saved version of the Activeworkbook
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.to = "ron@debruin.nl"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send ' <--------------------------------This is causing troubble
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Run Code Online (Sandbox Code Playgroud)
问题是.Send不被识别为对象(或方法).
其他命令正在工作(即显示,保存).
我相信这个错误是因为我工作的安全系统而存在的.我甚至尝试使用CDO,它不工作以太.