翻譯|使用教程|編輯:況魚杰|2020-01-16 10:25:23.680|閱讀 274 次
概述:本示例將會展示發(fā)送帶有2個附件的純文本電子郵件的操作。第一個附件以其自然名稱放入郵件中。第二個附件以不同的名稱放置(從臨時文件添加附件時經(jīng)常使用)。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
MailBee Objects是一個組件集合。您可以使用該控件創(chuàng)建并將郵件發(fā)送到SMTP服務(wù)器并從POP3服務(wù)器接收、解析以及刪除電子郵件,還能在IMAP4服務(wù)器上管理電子郵件以及文件夾。它同樣支持SSL以及S/MIME以獲得更好的安全性能。MailBee控件能在ASP、VB、C++或任何支持ActiveX技術(shù)的語言中使用。
本示例將會展示發(fā)送帶有2個附件的純文本電子郵件的操作。第一個附件以其自然名稱放入郵件中。第二個附件以不同的名稱放置(從臨時文件添加附件時經(jīng)常使用)。
SMTP.AddAttachment是示例的關(guān)鍵屬性。為簡單起見,不使用SMTP身份驗證,并且不執(zhí)行錯誤檢查。
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 attachments" ' Add attachment from "file1.doc" file. ' It will appear as "file1.doc" in the e-mail. objSMTP.AddAttachment "C:\files\file1.doc" ' Add attachment from "file2.tmp" file. ' It will appear as "renamed.doc" in the e-mail. objSMTP.AddAttachment "C:\files\file2.tmp", , ,"renamed.doc" ' 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 attachments" ' Add attachment from "file1.doc" file. ' It will appear as "file1.doc" in the e-mail. objSMTP.AddAttachment "C:\files\file1.doc" ' Add attachment from "file2.tmp" file. ' It will appear as "renamed.doc" in the e-mail. objSMTP.AddAttachment "C:\files\file2.tmp", , ,"renamed.doc" ' Send it! objSMTP.Send %>發(fā)送方式
將郵件發(fā)送到SMTP服務(wù)器。要從假地址發(fā)送,請使用SendEx方法。從組郵件中常用的偽地址發(fā)送郵件,以確保退回郵件都到達同一地址。
注意:許多SMTP服務(wù)器需要用戶身份驗證才能發(fā)送電子郵件。有關(guān)詳細信息,請參見AuthMethod屬性參考。下面的示例代碼使用身份驗證。如果服務(wù)器不需要或不支持它,請注釋相應(yīng)的行或僅設(shè)置AuthMethod = 0。
blnResult = ObjectName.Send
使用例子
Dim Mailer 'Using visual basic to create object Set Mailer = CreateObject("MailBee.SMTP") 'Using ASP to create object 'Set Mailer = Server.CreateObject("MailBee.SMTP") 'In ASP use Response.Write instead of MsgBox Mailer.LicenseKey = "put your license key here" Mailer.ServerName = "mail.server.com" ' Comment next 3 lines if authentication is not required. Mailer.AuthMethod = 1 ' Using PLAIN authentication Mailer.UserName = "MyUserName" ' Mail account name Mailer.Password = "MyPassword" ' Mail account password If Mailer.Connect Then Mailer.Message.ToAddr = "bill@yoursite.com" Mailer.Message.FromAddr = "joe@mysite.com" Mailer.Message.Subject = "Hello" Mailer.Message.ImportBodyText "C:\docs\letter.htm", True If Not Mailer.Send Then MsgBox Mailer.ErrDesc Mailer.Disconnect End If
==========================================
如果想要購買正版授權(quán)MailBee.NET Objects的朋友,可以聯(lián)系
關(guān)注慧聚IT微信公眾號 ???,了解產(chǎn)品的最新動態(tài)及最新資訊。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: