ASP ile CDOSYS ile E-posta Gönderme

CDOSYS, ASP içinde yerleşik bir bileşendir. Bu bileşen, ASP aracılığıyla e-posta göndermek için kullanılır.

CDOSYS ile e-posta gönderme

CDO (İşbirliği Veri Nesneleri), iletişim programlarının oluşturulmasını kolaylaştırmak amacıyla tasarlanmış bir Microsoft teknolojisidir.

CDOSYS, ASP içinde yerleşik bir bileşendir. Bu bileşeni nasıl kullanarak e-posta gönderileceğini göstereceğiz.

CDONTs nasıl?

Microsoft, Windows 2000, Windows XP ve Windows 2003'te CDONTs'yi ortadan kaldırmıştır. CDONTs'yi hala uygulamalarınızda kullanıyorsanız, kodunuzu güncellemelisiniz ve yeni CDO teknolojisini kullanmalısınız.

CDOSYS örneği kullanarak

E-posta gönderin:

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="CDO ile e-posta gönderme"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="Bu bir mesajdır."
myMail.Send
set myMail=nothing
%>

Bcc ve CC alanları ile metin e-postası gönderin:

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="CDO ile e-posta gönderme"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.Bcc="someoneelse@somedomain.com"
myMail.Cc="someoneelse2@somedomain.com"
myMail.TextBody="Bu bir mesajdır."
myMail.Send
set myMail=nothing
%>

HTML e-posta gönderin:

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="CDO ile e-posta gönderme"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.HTMLBody = "<h1>Bu bir mesajdır.</h1>" 
myMail.Send
set myMail=nothing
%>

Web sitesinden gelen HTML e-postası gönderin:

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="CDO ile e-posta gönderme"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.CreateMHTMLBody "http://www.codew3c.com/asp/" 
myMail.Send
set myMail=nothing
%>

Bilgisayardan dosya gelen HTML e-postası gönderin:

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="CDO ile e-posta gönderme"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.CreateMHTMLBody "file://c:/mydocuments/test.htm" 
myMail.Send
set myMail=nothing
%>

Ekli dosya içeren bir e-posta gönderin:

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="CDO ile e-posta gönderme"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="Bu bir mesajdır."
myMail.AddAttachment "c:\mydocuments\test.txt"
myMail.Send
set myMail=nothing
%>

Uzaktan sunucu kullanarak metin e-postası gönderin:

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="CDO ile e-posta gönderme"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="Bu bir mesajdır."
myMail.Configuration.Fields.Item _
(http://schemas.microsoft.com/cdo/configuration/sendusing)=2
'uzaktan SMTP sunucusunun IP adresi veya adı
myMail.Configuration.Fields.Item _
(http://schemas.microsoft.com/cdo/configuration/smtpserver) _
="smtp.server.com"
'sunucu bağlantı noktası
myMail.Configuration.Fields.Item _
(http://schemas.microsoft.com/cdo/configuration/smtpserverport) _
=25 
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing
%>