I use the following code to send e-mails via CDO. Everything works like a treat except the attachment. I don't know why the attachment files got corrupted (receivers could open the file except the .txt files ).
Dim oCDO As Object
Dim oCDOConfig As Object
Const c_sUsername As String = ""
Const c_sPassword As String = ""
Const c_sPickupFolder As String = "C:\"
Const c_iSMPTPort As Integer = 25
Dim iSendUsing As Integer
Dim sSMPTServerName As String
iSendUsing = 2 'remote host
' iSendUsing = 1 'localhost
' sSMPTServerName = "localhost"
sSMPTServerName = ""
Set oCDO = CreateObject("CDO.Message")
Set oCDOConfig = CreateObject("CDO.Configuration")
With oCDOConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = iSendUsing
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sSMPTServerName
.Item("http://schemas.microsoft.com/cdo/configuration/username") = c_sUsername
.Item("http://schemas.microsoft.com/cdo/configuration/password") = c_sPassword
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = c_iSMPTPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = c_sPickupFolder
End With
With oCDO
Set .Configuration = oCDOConfig
.From = ""
.To = ""
.Subject = ""
.AddAttachment ""
.Configuration.Fields.Update
.Send
End With
Set oCDOConfig = Nothing
Set oCDO = Nothing
End Sub
Please help ...
Thanks
Bookmarks