翻譯|使用教程|編輯:況魚杰|2020-02-24 16:45:15.837|閱讀 184 次
概述:本文將會介紹如何在MailBee Objects中添加自定義標題以及如何使用SMTP驗證。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
MailBee Objects是一個組件集合。您可以使用該控件創建并將郵件發送到SMTP服務器并從POP3服務器接收、解析以及刪除電子郵件,還能在IMAP4服務器上管理電子郵件以及文件夾。它同樣支持SSL以及S/MIME以獲得更好的安全性能。MailBee控件能在ASP、VB、C++或任何支持ActiveX技術的語言中使用。
本示例發送帶有在標頭中設置組織:字段的純文本電子郵件。SMTP.AddHeader是示例的關鍵方法。但本示例為簡單起見,不使用SMTP身份驗證,并且不執行錯誤檢查。
Visual Basic:
Dim objSMTP ' Create mailer component Set objSMTP = CreateObject("MailBee.SMTP") ' Unlock SMTP component objSMTP.LicenseKey = "put your license key here" ' Set SMTP server name objSMTP.ServerName = "mail.server.com" ' Set message properties objSMTP.FromAddr = "me@mydomain.com" objSMTP.ToAddr = "you@yourdomain.com" objSMTP.Subject = "Hi" objSMTP.BodyText = "This is test message with custom headers" ' Add "Organization" header objSMTP.AddHeader "Organization", "Corporation, Inc." ' Send it! objSMTP.SendASP:
<% Dim objSMTP ' Create mailer component Set objSMTP = Server.CreateObject("MailBee.SMTP") ' Unlock SMTP component objSMTP.LicenseKey = "put your license key here" ' Set SMTP server name objSMTP.ServerName = "mail.server.com" ' Set message properties objSMTP.FromAddr = "me@mydomain.com" objSMTP.ToAddr = "you@yourdomain.com" objSMTP.Subject = "Hi" objSMTP.BodyText = "This is test message with custom headers" ' Add "Organization" header objSMTP.AddHeader "Organization", "Corporation, Inc." ' Send it! objSMTP.Send %>SMTP驗證
本示例將會使用SMTP身份驗證發送簡單的電子郵件。
許多郵件服務器僅允許從經過身份驗證的用戶發送電子郵件。要進行身份驗證,您需要指定用戶帳戶名,密碼和身份驗證方法。
身份驗證方法可以有兩種:安全(密碼以安全格式發送到服務器)和不安全(密碼以純文本格式發送)。 許多SMTP服務器僅支持不安全的方法。
SMTP對象通過AuthMethod屬性支持多種身份驗證方法(安全和不安全)。 某些SMTP服務器可能不支持其中的一些。
Visual Basic:
Dim objSMTP, strTemp ' Create mailer component Set objSMTP = CreateObject("MailBee.SMTP") ' Unlock SMTP component objSMTP.LicenseKey = "put your license key here" ' Set SMTP server name objSMTP.ServerName = "mail.server.com" ' Use LOGIN Authentication method (insecure, but ' supported by nearly all SMTP servers) objSMTP.AuthMethod = 2 ' Set authentication credentials objSMTP.UserName = "jdoe" objSMTP.Password = "secret" ' Set message properties objSMTP.FromAddr = "sender@firstdomain.com" objSMTP.ToAddr = "recipient@seconddomain.com" objSMTP.Subject = "Test" objSMTP.BodyText = "Body of the test message" ' Try to send message If objSMTP.Send Then MsgBox "Sent successfully" Else MsgBox "Error #" & objSMTP.ErrCode & ", " & objSMTP.ErrDesc End IfASP:
<% Dim objSMTP, strTemp ' Create mailer component Set objSMTP = Server.CreateObject("MailBee.SMTP") ' Unlock SMTP component objSMTP.LicenseKey = "put your license key here" ' Set SMTP server name objSMTP.ServerName = "mail.server.com" ' Use LOGIN Authentication method (insecure, but ' supported by nearly all SMTP servers) objSMTP.AuthMethod = 2 ' Set authentication credentials objSMTP.UserName = "jdoe" objSMTP.Password = "secret" ' Set message properties objSMTP.FromAddr = "sender@firstdomain.com" objSMTP.ToAddr = "recipient@seconddomain.com" objSMTP.Subject = "Test" objSMTP.BodyText = "Body of the test message" ' Try to send message If objSMTP.Send Then Response.Write "Sent successfully" Else Response.Write "Error #" & objSMTP.ErrCode & ", " & objSMTP.ErrDesc End If %>
==========================================
如果想要購買正版授權MailBee.NET Objects的朋友,可以聯系
關注慧聚IT微信公眾號 ???,了解產品的最新動態及最新資訊。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: