翻譯|使用教程|編輯:況魚(yú)杰|2020-01-16 10:25:23.680|閱讀 283 次
概述:本示例將會(huì)展示發(fā)送帶有2個(gè)附件的純文本電子郵件的操作。第一個(gè)附件以其自然名稱(chēng)放入郵件中。第二個(gè)附件以不同的名稱(chēng)放置(從臨時(shí)文件添加附件時(shí)經(jīng)常使用)。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
MailBee Objects是一個(gè)組件集合。您可以使用該控件創(chuàng)建并將郵件發(fā)送到SMTP服務(wù)器并從POP3服務(wù)器接收、解析以及刪除電子郵件,還能在IMAP4服務(wù)器上管理電子郵件以及文件夾。它同樣支持SSL以及S/MIME以獲得更好的安全性能。MailBee控件能在ASP、VB、C++或任何支持ActiveX技術(shù)的語(yǔ)言中使用。
本示例將會(huì)展示發(fā)送帶有2個(gè)附件的純文本電子郵件的操作。第一個(gè)附件以其自然名稱(chēng)放入郵件中。第二個(gè)附件以不同的名稱(chēng)放置(從臨時(shí)文件添加附件時(shí)經(jīng)常使用)。
SMTP.AddAttachment是示例的關(guān)鍵屬性。為簡(jiǎn)單起見(jiàn),不使用SMTP身份驗(yàn)證,并且不執(zhí)行錯(cuò)誤檢查。
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ā)送,請(qǐng)使用SendEx方法。從組郵件中常用的偽地址發(fā)送郵件,以確保退回郵件都到達(dá)同一地址。
注意:許多SMTP服務(wù)器需要用戶(hù)身份驗(yàn)證才能發(fā)送電子郵件。有關(guān)詳細(xì)信息,請(qǐng)參見(jiàn)AuthMethod屬性參考。下面的示例代碼使用身份驗(yàn)證。如果服務(wù)器不需要或不支持它,請(qǐng)注釋相應(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
==========================================
如果想要購(gòu)買(mǎi)正版授權(quán)MailBee.NET Objects的朋友,可以聯(lián)系
關(guān)注慧聚IT微信公眾號(hào) ???,了解產(chǎn)品的最新動(dòng)態(tài)及最新資訊。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn
文章轉(zhuǎn)載自: