Paul H wrote:
Well I guess I am looking for the "elegant" solution :O)
hour of pain working this one out! just substitute the [] fields and
include the Miscrosoft CDO library - no outlook profiles required:
Sub SendHTMLMail(st rTo As String, strSubject As String, strBody As
String)
'============== =============== =============== ========
'Bill Coleman
'20th April 06
'Sends email HTML email directly via exchange server, w/o outlook
'============== =============== =============== ========
Dim iCfg As CDO.Configurati on
Dim iMsg As CDO.Message
Set iCfg = New CDO.Configurati on
With iCfg
.Fields(cdoSMTP Server) = "[EXCHANGE SERVER NAME]"
.Fields(cdoSMTP ServerPort) = 25 ' typically
.Fields(cdoSend UsingMethod) = cdoSendUsingPor t
.Fields(cdoSMTP ConnectionTimeo ut) = 200
.Fields.Update
End With
Set iMsg = New CDO.Message
With iMsg
Set .Configuration = iCfg
.From = "[Name Of Sender]"
.Sender = "[Me@Whatever.com]"
.ReplyTo = "[Me@Whatever.com]"
.Subject = strSubject
.HTMLBody = strBody
.To = strTo
.Send
End With
Set iMsg = Nothing
Set iCfg = Nothing
End Sub