
12-12-2007, 12:47 PM
|
|
Centurion
|
|
Join Date: Feb 2002
Location: Ohio, USA
Posts: 104
|
|
I use CDO to send emails
Code:
Public Sub SendEmail(strTo As String, strFrom As String, strSubject As String, strMsg As String, strAttachPath As String)
Dim iMsg As New CDO.Message
Dim iConf As New CDO.Configuration
Dim Flds As ADODB.Fields
On Error GoTo errorhandler
Screen.MousePointer = vbHourglass
Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp.smtpserver.com"
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = 0
.Item(cdoSendUserName) = "USERID"
.Item(cdoSendPassword) = "PASSWORD"
.Item(cdoURLProxyServer) = "yourproxyserver:80"
.Item(cdoURLProxyBypass) = "<local>"
.Item(cdoURLGetLatestVersion) = True
.Update
End With
With iMsg
Set .Configuration = iConf
.To = strTo
.From = strFrom
.Subject = strSubject
.TextBody = strMsg
If strAttachPath <> "" Then
.AddAttachment strAttachPath
End If
.Send
If Err.Number <> 0 Then
MsgBox "CDO Send error: " & "&H" & Hex$(Err.Number) & vbNewLine _
& Err.Description, vbOKOnly Or vbExclamation, App.EXEName
End If
End With
Set Flds = Nothing
Screen.MousePointer = vbNormal
Exit Sub
errorhandler:
MsgBox "Error " & Err.Number & ": " & Err.Description
Err.Clear
Screen.MousePointer = vbNormal
End Sub
|
|