邮件组件集合MailBee Objects发送电子邮件教程(五):添加自定义标题和SMTP验证

本文将会介绍如何在MailBee Objects中添加自定义标题以及如何使用SMTP验证。

MailBee Objects是一个组件集合。您可以使用该控件创建并将邮件发送到SMTP服务器并从POP3服务器接收、解析以及删除电子邮件,还能在IMAP4服务器上管理电子邮件以及文件夹。它同样支持SSL以及S/MIME以获得更好的安全性能。MailBee控件能在ASP、VB、C++或任何支持ActiveX技术的语言中使用。

最新版MailBee Objects


本示例发送带有在标头中设置组织:字段的纯文本电子邮件。SMTP.AddHeader是示例的关键方法。但本示例为简单起见,不使用SMTP身份验证,并且不执行错误检查。

Visual Basic

Dim objSMTP' Create mailer componentSet objSMTP = CreateObject("MailBee.SMTP")' Unlock SMTP componentobjSMTP.LicenseKey = "put your license key here"' Set SMTP server nameobjSMTP.ServerName = "mail.server.com"' Set message propertiesobjSMTP.FromAddr = "me@mydomain.com"objSMTP.ToAddr = "you@yourdomain.com"objSMTP.Subject = "Hi"objSMTP.BodyText = "This is test message with custom headers"' Add "Organization" headerobjSMTP.AddHeader "Organization", "Corporation, Inc."' Send it!objSMTP.Send

ASP:

<% 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 componentSet objSMTP = CreateObject("MailBee.SMTP")' Unlock SMTP componentobjSMTP.LicenseKey = "put your license key here"' Set SMTP server nameobjSMTP.ServerName = "mail.server.com"' Use LOGIN Authentication method (insecure, but' supported by nearly all SMTP servers)objSMTP.AuthMethod = 2' Set authentication credentialsobjSMTP.UserName = "jdoe"objSMTP.Password = "secret"' Set message propertiesobjSMTP.FromAddr = "sender@firstdomain.com"objSMTP.ToAddr = "recipient@seconddomain.com"objSMTP.Subject = "Test"objSMTP.BodyText = "Body of the test message"' Try to send messageIf objSMTP.Send Then  MsgBox "Sent successfully"Else  MsgBox "Error #" & objSMTP.ErrCode & ", " & objSMTP.ErrDescEnd If

ASP:

<% 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微信公众号 了解产品的最新动态及最新资讯。

标签:

来源:慧都

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年1月20日
下一篇 2020年1月20日

相关推荐

发表回复

登录后才能评论