ASP Wysyłanie e-maili za pomocą CDOSYS
CDOSYS jest wbudowanym komponentem w ASP. Ten komponent służy do wysyłania e-maili z ASP.
Wysyłanie e-maili za pomocą CDOSYS
CDO (Collaboration Data Objects) to technologia firmy Microsoft zaprojektowana w celu uproszczenia tworzenia aplikacji do przesyłania wiadomości.
CDOSYS jest wbudowanym komponentem w ASP. Pokażemy Ci, jak używać tego komponentu do wysyłania e-maili z ASP.
Co powiesz na CDONT?
Firma Microsoft zaprzestała używania CDONT w systemach Windows 2000, Windows XP i Windows 2003. Jeśli używałeś CDONT w swoich aplikacjach ASP, powinieneś zaktualizować kod i użyć nowej technologii CDO.
Przykłady wykorzystania CDOSYS
Wysyłanie sms-a e-mail:
<%
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
%>
Wysyłanie wiadomości tekstowej e-mail z polami UDW i DW:
<%
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
%>
Wysyłanie wiadomości e-mail w formacie 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
%>
Wysyłanie wiadomości e-mail w formacie HTML, która wysyła stronę internetową ze strony internetowej:
<%
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
%>
Wysyłanie wiadomości e-mail w formacie HTML, która wysyła stronę internetową z pliku na komputerze:
<%
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
%>
Wysłanie sms-a z Załącznikiem:
<%
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
%>
Wysyłanie wiadomości tekstowej e-mail za pomocą zdalnego serwera:
<%
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
%>