CDO : Set objMessage = CreateObject("CDO.Message")
- old CDONTS : Set objMessage = Server.CreateObject("CDONTS.Message")
Description:
Set objMessage = Server.CreateObject("CDO.Message")
sending TEXT : objMessage.TextBody
sending HTML : objMessage.HTMLBody
sending Attachment : objMessage.AddAttachment
------all email shall contain with an email@address-----
objMessage.To = "to@---.com"
objMessage.From = "from@---.com"
objMessage.Bcc = "Bcc@---.com"
objMessage.Cc = "Cc@---.com"
------------- objMessage.send -------------
you may have 2 or more
objMessage.send
objMessage2.send
objMessage3.send
in on script
-------------------Server Address----------------
it is different with Server.CreateObject("JMail.SMTPMail")
when use Server.CreateObject("CDO.Message")
you do not list your Server Address in the script
-------- How yahoo receive this kind of email-----
yahoo treat this kind of auto send out letter as
bulk email unless the address is listed on
your address book
------------- Every email has an ID -------------
!!! Do not send junk emails !!!
Each email has its own ID and mail server name...
Your local server shall also receive each email ID
---- sending File : objMessage.AddAttachment ----
<%
Dim objMessage
Set objMessage = CreateObject("CDO.Message")
objMessage.To = "to@---.com"
objMessage.From = "from@---.com"
objMessage.Bcc = "Bcc@---.com"
objMessage.Cc = "Cc@---.com"
objMessage.Subject = "Subject"
objMessage.AddAttachment "c:\a-file.txt"
objMessage.send
'free up the the computer memory
Set objMessage = Nothing
%>
----sending TEXT : objMessage.TextBody----
<%
Dim objMessage
Set objMessage = CreateObject("CDO.Message")
objMessage.To = "to@---.com"
objMessage.From = "from@---.com"
objMessage.Bcc = "Bcc@---.com"
objMessage.Cc = "Cc@---.com"
objMessage.Subject = "Subject"
objMessage.TextBody = "sending text only"
objMessage.send
'free up the the computer memory
Set objMessage = Nothing
%>
----sending HTML : objMessage.HTMLBody----
<%
Dim objMessage
Set objMessage = CreateObject("CDO.Message")
objMessage.To = "to@---.com"
objMessage.From = "from@---.com"
objMessage.Bcc = "Bcc@---.com"
objMessage.Cc = "Cc@---.com"
objMessage.Subject = "Subject"
objMessage.HTMLBody="<b>CDO HTML mail example</b><br>"
objMessage.HTMLBody=objMessage.HTMLBody&"a test html email"
objMessage.HTMLBody=objMessage.HTMLBody&"<br>a line<hr>"
objMessage.HTMLBody=objMessage.HTMLBody&"<br>Regards,"
objMessage.HTMLBody=objMessage.HTMLBody&"<br>Ezer"
objMessage.send
'free up the the computer memory
Set objMessage = Nothing
%>
-----------------err message code--------------
strErr = ""
On Error Resume Next ' catch errors
If Err <> 0 Then ' error occurred
strErr = Err.Description
response.write "CDO email error occurred : <br>"
response.write "Error: "&strErr&"<br>"&vbcrlf
else
response.write "CDO email sent out with no error"
End If
--------------------------------------
CDONTS = C DON'T S , FOR old NT use so don't use it any more
Example Result:
TEXT :: sending text only
HTML ::
CDO HTML mail example
a test html email
a line
Regards, Ezer
For the mail body info you may write like this way
If you are writing a text form then just take off html tags.
<%
bodyinfo="Dear receiver,<br>"
bodyinfo=bodyinfo&"It is nice to talk to you<br>"
bodyinfo=bodyinfo&"May this method helps you.<p>"
bodyinfo=bodyinfo&"Best Regards,<br>"
bodyinfo=bodyinfo&"3w.ezer.com"
objMessage.HTMLBody = bodyinfo
%>