CDOSYS adalah komponen built-in di ASP. Komponen ini digunakan untuk mengirim e-mail dengan ASP.
Mengirim e-mail dengan CDOSYS
CDO (Collaboration Data Objects) adalah teknologi Microsoft yang dirancang untuk menyederhanakan pembuatan aplikasi messaging.
CDOSYS adalah komponen built-in di ASP. Kami akan menunjukkan kepada Anda bagaimana menggunakan komponen ini untuk mengirim e-mail dengan ASP.
Bagaimana CDONTS?
Microsoft telah menghentikan penggunaan CDONTS pada Windows 2000, Windows XP dan Windows 2003. Jika Anda telah menggunakan CDONTS dalam aplikasi ASP Anda, Anda harus memperbarui kode dan menggunakan teknologi CDO baru.
Contoh menggunakan CDOSYS
Mengirim e-mail teks:
<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.TextBody = "This is a message."
myMail.Send
set myMail = nothing
%>
Mengirim e-mail teks dengan bidang Bcc dan CC:
<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.Bcc = "[email protected]"
myMail.Cc = "[email protected]"
myMail.TextBody = "This is a message."
myMail.Send
set myMail = nothing
%>
Mengirim e-mail HTML:
<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.HTMLBody = "<h1>This is a message.</h1>"
myMail.Send
set myMail = nothing
%>
Mengirim e-mail HTML yang mengirimkan halaman web dari sebuah situs web:
<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "[email protected]"
myMail.To ="[email protected]"
myMail.CreateMHTMLBody = "http://www.w3ii.com/asp/"
myMail.Send
set myMail = nothing
%>
Mengirim e-mail HTML yang mengirimkan halaman web dari sebuah file di komputer Anda:
<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.CreateMHTMLBody = "file://c:/mydocuments/test.htm"
myMail.Send
set myMail = nothing
%>
Mengirim e-mail teks dengan Lampiran:
<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.TextBody = "This is a message."
myMail.AddAttachment = "c:\mydocuments\test.txt"
myMail.Send
set myMail = nothing
%>
Mengirim e-mail teks menggunakan remote server:
<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.TextBody = "This is a message."
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.server.com"
'Server port
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
myMail.Configuration.Fields.Update
myMail.Send
set myMail = nothing
%>