ASP Stuur e-pos met CDOSYS


CDOSYS is 'n ingeboude komponent in ASP. Hierdie komponent word gebruik om e-posse met ASP te stuur.


Stuur e-pos met CDOSYS

CDO (Collaboration Data Objects) is 'n Microsoft-tegnologie wat ontwerp is om die skepping van boodskaptoepassings te vereenvoudig.

CDOSYS is 'n ingeboude komponent in ASP. Ons sal jou wys hoe om hierdie komponent te gebruik om e-pos met ASP te stuur.

Wat van CDONT's?

Microsoft het die gebruik van CDONT'e op Windows 2000, Windows XP en Windows 2003 gestaak. As jy CDONT'e in jou ASP-toepassings gebruik het, moet jy die kode opdateer en die nuwe CDO-tegnologie gebruik.

Voorbeelde wat CDOSYS gebruik

Stuur 'n teks-e-pos:

<%
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
%>

Stuur 'n teks-e-pos met Bcc- en CC-velde:

<%
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
%>

Stuur 'n HTML-e-pos:

<%
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
%>

Stuur 'n HTML-e-pos wat 'n webblad vanaf 'n webwerf stuur:

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "[email protected]"
myMail.To ="[email protected]"
myMail.CreateMHTMLBody "https://www.w3schools.com/asp/"
myMail.Send
set myMail = nothing
%>


Stuur 'n HTML-e-pos wat 'n webblad vanaf 'n lêer op jou rekenaar stuur:

<%
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
%>

Stuur 'n teks-e-pos met 'n aanhegsel:

<%
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
%>

Stuur 'n teks-e-pos met 'n afgeleë bediener:

<%
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
%>