"Salgoud Dell" <no****@cfu.net> wrote in message
news:ch**********@news.cfu.net...
I have a project within which I need to send an automatically produced
report to a client list. Can anyone point me to documentation on
implimenting an email sending routine within a VB6 program? Code samples?
Thanks
Sal in Iowa
Here's a function I used to use ages ago - I've since created a .NET
version, so I can't gaurantee that it ever worked (!), but it should give
you some pointers if it doesnt. It makes use of Microsoft's CDO library, so
you will prob. need that installed - I recommend reading up about it, and
CDONTS as well - a simple google search should yield loads of results.
**************** CODE ****************
Public Function fSendMailCDO(sTo As String, sFrom As String, sSubject As
String, sMessage As String) As Boolean
'Returns true if the message was sent, else return's false
'This function cannot guarantee the e-mail was recieved and/or read.
On Error GoTo errorHandler
Dim objConf As New CDO.Configuration
Dim objMessage As New CDO.Message
objConf.Fields.Item(cdoSendUsingMethod).value = 2
objConf.Fields.Item(cdoSMTPServer).value = "skinner"
objConf.Fields.Update
objMessage.Configuration = objConf
objMessage.From = sFrom
objMessage.To = sTo
objMessage.HTMLBody = sMessage
objMessage.Subject = sSubject
objMessage.Send
fSendMailCDO = True
Exit Function
errorHandler:
Select Case err.Number
Case -2147220977: 'E-mail address rejected
Debug.Print fGetErrorLogPrefix + vbCrLf + _
"ERROR: EMAIL ADDRESS REJECTED" + vbCrLf + _
err.Description + vbCrLf + vbCrLf
Case Else
Debug.Print fGetErrorLogPrefix + vbCrLf + _
"UNHANDLED EXCEPTION in fSendMail" + vbCrLf + _
CStr(err.Number) + vbCrLf + _
err.Description
End Select
fSendMailCDO = False
End Function
**************** END CODE ****************
HTH,
Rowland.