2017年9月1日 星期五

[ASP]使用CDONT寄送email

最近羊男需要使用古老的技術ASP寫個客戶留言版,此需求要將留言內容email寄送至員工信箱
於是我翻開十年前的老書上看到有個方法要在windows server 2000上安裝SMTP虛擬伺服器,
這是一種類似SMTP代理伺服器的服務,此服務也提供email relay的功能,不過既然己經有exchange server可以寄信了,何必多此一舉,於是使用連至Exchage Server來寄信,程式碼如下:

<%
Set Email = Server.CreateObject("CDO.Message"); 'CDO.Message 是 Windows 2000 內建傳送email 元件,它許多功能(html格式、透過exchange server寄信、可設定編碼)
Email.From ="aa@hotmail.com" '寄件者
Email.To ="xx@hotmail.com" '收件者
Email.Subject ="XX實業來信" '主旨
Email.HtmlBody ="<html><body>simple content</body></html>" 
Email.BodyPart.Charset = "big5"
Set Conf = CreateObject("CDO.Configuration") 
Set Flds = Conf.Fields 
With Flds 
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 '使用網路上傳送訊息
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1"  'Exchange Server IP
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 '使用的port
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "testacount" '帳號
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password" '密碼
.Update '整批更新剛才的設定
End With
Email.Configuratoin = Conf
Email.Send '寄送email
Set Email = nothing '清除此物件
Set Conf = nothing
%>

如有問題,歡迎留言指教~

參考資料:

1 則留言:

  1. How to play pokies at your casino
    In this video I'll 포항 출장마사지 show you how to play pokies with 안산 출장안마 Pinnacle Sports, a well respected brand for betting 제천 출장마사지 and casino games. We also 서귀포 출장안마 have a 안양 출장샵 full

    回覆刪除

[SQL Server]主動通知SQL Server發生錯誤的機制

當SQL Server有特定錯誤發生時,管理人員也沒有時間經常去查看SQL Server錯誤檔, 於是有時特定錯誤可能很重要時,但卻沒有人被通知到,現在小弟實作一個主動通知的機制。 首先先新增警示,在這裡選擇想要被通知的錯誤訊息的等級或其它設定 接著在回應頁籤中,勾選執...