|
程式語言:Classic asp
測試環境:Windows 10 IIS 10.0
測試郵件伺服器:office365
說明:本文僅在紀錄如何在classic asp環境下使用CDO.Messgae寄信時設定"重要性"。其他的寄信設定方式僅供參考。
Set myMail=CreateObject("CDO.Message")
myMail.BodyPart.Charset = "utf-8" '設置郵件編碼 UTF-8
myMail.Subject= MailSubject '郵件標題
myMail.From= FromMail '發信人
myMail.Bcc=BCCToMailList '密件副本
myMail.Cc=CCToMailList '一般副本
myMail.HTMLBody = "<p>This is Message </p>" '郵件 HTML內容
myMail.TextBody= "This is Message" '郵件純文字內容
myMail.TextBodyPart.ContentTransferEncoding = "quoted-printable" '991截斷問題
myMail.HTMLBodyPart.ContentTransferEncoding = "quoted-printable" '991截斷問題
With myMail.Configuration
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") =2
'遠端SMTP主機名稱或IP位址
.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="伺服器IP"
'遠端SMTP主機埠號 Server port
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = false
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "userPassowrd"
'====以下為錯誤示範,網路上很多範例會將優先權設定寫在.Configuration 底下的.Fields.Item
' 實際上,這樣設定並沒有效果。(在Outlook2016收信時的實測結果)
' ==== Do NOT USE ↓↓↓↓↓</font>
'.Fields.Item("urn:schemas:mailheader:X-Priority") = 2 '*** 0=Low,1=Normal,2=High ***'
'.Fields.Item("urn:schemas:mailheader:X-MSMail-Priority") = 2
'.Fields.Item("urn:schemas:httpmail:importance") = "High"
'.Fields.Item("urn:schemas:mailheader:importance").Value ="high" 'you can set [high,normal,low] for this field
'.Fields.Item("urn:schemas:mailheader:priority" ).Value = 1 'youcan set [1, 0 , -1] for this field
' ==== Do NOT USE 以上為錯誤示範 ↑↑↑↑↑
End With 'End With myMail.Configuration
' 正確的作法是要在CDO.Message下的.Fields設定優先權
myMail.Fields.Item("urn:schemas:mailheader:importance").Value ="high" 'you can set [high,normal,low] for this field
myMail.Fields.Item("urn:schemas:mailheader:priority" ).Value = 1 'youcan set [1, 0 , -1] for this field
myMail.Fields.Update
myMail.Configuration.Fields.Update
|
|