ASPCDOSYSを使用した電子メールの送信
CDOSYSは、ASPに組み込まれているコンポーネントです。このコンポーネントは、ASPを使用して電子メールを送信するために使用されます。
CDOSYSを使用した電子メールの送信
CDO(Collaboration Data Objects)は、メッセージングアプリケーションの作成を簡素化するように設計されたMicrosoftテクノロジです。
CDOSYSは、ASPに組み込まれているコンポーネントです。このコンポーネントを使用してASPで電子メールを送信する方法を説明します。
CDONTはどうですか?
Microsoftは、Windows 2000、Windows XP、およびWindows 2003でのCDONTの使用を中止しました。ASPアプリケーションでCDONTを使用した場合は、コードを更新して新しいCDOテクノロジを使用する必要があります。
CDOSYSを使用した例
テキストメールの送信:
<%
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
%>
Bccおよび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
%>
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
%>
WebサイトからWebページを送信するHTML電子メールの送信:
<%
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
%>
コンピューター上のファイルからWebページを送信するHTML電子メールの送信:
<%
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
%>
添付ファイル付きのテキスト電子メールの送信:
<%
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
%>
リモートサーバーを使用してテキスト電子メールを送信する:
<%
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
%>