Sub CDO_Send_ActiveSheet_Body()
' This example use late binding, you don't have to set a reference
' You must be online when you run the sub
Dim iMsg As Object
Dim iConf As Object
' Dim Flds As Variant Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration") ' iConf.Load -1 ' CDO Source Defaults
' Set Flds = iConf.Fields
' With Flds
' .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Fill in your SMTP server here"
' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' .Update
' End With 'Check out the Tips section if you want to change the .To and .TextBody
With iMsg
Set .Configuration = iConf '调试到这里说是变量未定义,iConf=Nothing
.To = "samples@123.COM"
.CC = ""
.BCC = ""
.From = """Ron"" <samples@123.com>"
.Subject = "This is a test"
.HTMLBody = SheetToHTML(ActiveSheet)
.Send
End With Set iMsg = Nothing
Set iConf = Nothing
End Sub |