sample code of sending email using CDOSYS
Top : General Technical Support : Programming
| Article ID: |
 |
000086 |
| Rating: |
 |
3.0 / 5.0 (2 votes)
|
| Views: |
 |
3483 |
|
If you are using CDOSYS to send email in your code,you can compare this code with your own.
copy the following code to a new ASP code page and replace from@domain.com,to@domain.com with your from/to email address and test it out.
|
<%
'Send email using CDOSYS
If SendMessage("from@domain.com","to@domain.com", "", "Test message using CDOSYS",Request.ServerVariables("SERVER_NAME"), 0) Then
Response.Write "CDOSYS message test successfully!<BR>"
Else
Response.Write "CDOSYS message test failed!<BR>"
End If
%>
<%
Public Function SendMessage(strFrom, strTo, strBcc, strSubject, strBody,intMessageFormat)
Dim objMail, objConf
Dim bitSuccess
'On Error Resume Next
bitSuccess = False
Set objMail = Server.CreateObject("CDO.Message")
If IsObject(objMail) Then
Set objConf = Server.CreateObject("CDO.Configuration")
objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpport") = "25"
'objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
'objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\Inetpub\mailroot\Pickup"
objConf.Fields.Update
objMail.Configuration = objConf
If strFrom <> "" Then
objMail.From = strFrom
Else
objMail.From = "Guest"
End If
objMail.To = strTo
objMail.Bcc = strBcc
objMail.Subject = strSubject
If intMessageFormat = 1 Then 'Text
objMail.TextBody = strBody
Else
objMail.HTMLBody = strBody
End If
objMail.Send
bitSuccess = True
Set objConf = Nothing
Set objMail = Nothing
End If
SendMessage = bitSuccess
End Function
%>
|