Latest web development tutorials

ASP wykorzystuje CDOSYS wysłać e-mail

CDOSYS jest wbudowany składnik ASP. Składnik ten jest używany do wysyłania wiadomości e-mail za pomocą ASP.


Użyj CDOSYS wysłać e-mail

CDO (Collaboration Data Objects) to technologia Microsoft, zaprojektowane tak, aby uprościć tworzenie aplikacji komunikacyjnych.

CDOSYS jest wbudowany składnik ASP. Pokażemy Ci, jak korzystać z komponentów ASP, aby wysłać wiadomość.

CDONTS jak?

Microsoft ma w systemie Windows 2000, Windows XP i Windows 2003 są eliminowane CDONTS. Jeśli korzystasz już z CDONTS aplikacji ASP, musisz zaktualizować swój kod i korzystać z nowej technologii CDO.

Przykład CDOSYS

Wyślij e-mail tekst:

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

Wyślij e-mail tekst z BCC i CC dziedzinach:

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

Wyślij 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
%>

Wyślij zawartość strony witryny w HTML e-mail:

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

Wyślij zawartość strony na komputerze w pliku w formacie HTML e-mail:

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

Wyślij Wiadomość tekstową z załącznikami:

<%
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:mydocumentstest.txt"
myMail.Send
set myMail=nothing
%>

Użyj serwera zdalnego, aby wysłać tekst 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.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
%>