未找到

未发布 MailBee.NET Objects退回邮件教程(一):SMTP部分
by Harriet666 keys 分享 1503479866630
MailBee.NET Objects是一款为创建、发送、接收以及处理电子邮件而设计的健壮、功能丰富的.NET控件。几行代码便可为应用程序添加E-Mail支持,简单高效。具备“必需”以及独特的功能,这些控件帮助开发人员简单快速地将复杂的电子邮件功能添加到他们的应用程序中。
 
 
MailBee.NET Objects介绍和试用点击查看>>>
 
本文主要介绍了SMTP服务器退回邮件的代码示例。目前MailBee.NET Objects在线订购享75折优惠正在进行中,欢迎您下载试用版进行运用!

所有退回的电子邮件都应该到达一个邮箱地址。这里将其命名为我们的退件通知栏 - bounce@domain.com。显然,你需要确保退回的邮件能有它们的方式到达退件通知栏。
 
让我们看看这些邮件是如何由SMTP服务器发送的。当一封邮件提交给SMTP服务器时,它将被标记返回路径。返回路径是服务器用于与邮件的原始发送方通信的路径,因此返回路径通常是发件人的电子邮件地址(“From”地址)。
 
返回路径记录在邮件中。“From”用于显示发件人地址。返回路径和字段“From”中的地址不必一样。因此,您可以发送一个使用字段“From”的电子邮件显示发件人(jdoe@domain.com),但返回路径将是bounce box地址(bounce@domain.com)。有了这个技巧,所有的反弹消息都将返回到一个特殊的邮箱。
 
那么如何使用MailBee Objects呢?smtp.Send(senderEmail,recipient)方法向指定的收件人电子邮件地址发送电子邮件。第一个参数是发件人的电子邮件地址。如果是空引用,则电子邮件地址取自“From”属性。第二个参数包含收件人电子邮件地址的分隔列表。当第二个参数为空时,收件人列表可以由To、Cc和Bcc列表组合。正如你所看到的,第一个参数是我们组织一个退件栏所需要的。如果将退件栏地址设置为第一个参数,那么所有退回邮件将被发送到特殊地址。
 
注意:某些SMTP服务器不允许从“From”标头中指定的地址发送电子邮件。
 
代码示例:
 
此示例使用SMTP协议发送电子邮件。为了确保所有收件人都收到该邮件,TestSend将被调用。带有传送错误的邮件将来自指定的电子邮件地址。
C#
// Create SMTP object
Smtp mailer = new Smtp();

// Set the message fields.
mailer.From.AsString = "jdoe@domain.com";
mailer.To.AsString = "bill@domain2.com";
mailer.Subject = "Hi";
mailer.BodyPlainText = "This is test message";

// Starts logging SMTP activities into a file. 
mailer.Log.Enabled = true;
mailer.Log.Filename = @"C:\log.txt";
mailer.Log.Clear();

// Specify the server to use. If your server does not require authentication, 
// just omit both last parameters.
mailer.SmtpServers.Add("mail.domain.com", "jdoe", "secret");

// Attempt to connect.
mailer.Connect();

// Display the host name of the server the connection was established with.
Console.WriteLine("Connected to " + mailer.SmtpServers[mailer.GetCurrentSmtpServerIndex()].Name);

// Make sure all the recipients are ok.
if (mailer.TestSend(SendFailureThreshold.AllRecipientsFailed) != TestSendResult.OK)
{
        Console.WriteLine("No recipients can receive the message.");
}// Show refused recipients if any
else if (mailer.GetRefusedRecipients().Count > 0)
{
    Console.WriteLine("The following recipients failed: " + mailer.GetRefusedRecipients().ToString());
}
else
{
    Console.WriteLine("All recipients are ok. Will send the message now.");

    // Send e-mail. If it cannot be delivered, bounce will
    // arrive to bounce@domain3.com, not to joe@domain1.com
    mailer.Send("bounce@domain.com", (string)null);
    Console.WriteLine("Sent to: " + mailer.GetAcceptedRecipients().ToString());
}

// Disconnect from the server
mailer.Disconnect();
VB.NET
' Create SMTP object
Dim mailer As New Smtp

' Set the message fields.
mailer.From.AsString = "jdoe@domain.com"
mailer.To.AsString = "bill@domain2.com"
mailer.Subject = "Hi"
mailer.BodyPlainText = "This is test message"

' Starts logging SMTP activities into a file. 
mailer.Log.Enabled = True
mailer.Log.Filename = "C:\log.txt"
mailer.Log.Clear()

' Specify the server to use. If your server does not require authentication, 
' just remove last 2 parameters.
mailer.SmtpServers.Add("mail.domain.com", "jdoe", "secret")

' Attempt to connect.
mailer.Connect()

' Display the host name of the server the connection was established with.
Console.WriteLine("Connected to " + mailer.SmtpServers(mailer.GetCurrentSmtpServerIndex()).Name)

' Make sure all the recipients are ok.
If mailer.TestSend(SendFailureThreshold.AllRecipientsFailed) <> TestSendResult.OK Then
        Console.WriteLine("No recipients can receive the message.")
Else
    ' Show refused recipients if any
    If mailer.GetRefusedRecipients().Count > 0 Then
        Console.WriteLine("The following recipients failed: " & mailer.GetRefusedRecipients().ToString())
    Else
        Console.WriteLine("All recipients are ok. Will send the message now.")

        ' Send e-mail. If it cannot be delivered, bounce will
        ' arrive to bounce@domain3.com, not to joe@domain1.com
        mailer.Send("bounce@domain.com", CType(Nothing, String))
        Console.WriteLine("Sent to: " + mailer.GetAcceptedRecipients().ToString())
    End If
End If

' Disconnect from the server
mailer.Disconnect()

未发布 想要做好微分销系统,内容就一定要做好!
by 霁夜茶135 keys 分享 1499855117729
只有了解微分销系统,并且知道如何做微分销系统,才能够充分发挥微分销系统的作用,进而取得更好的效果。
未发布 2014年最受欢迎数据库Top5
by AABBbaby keys 分享 1419565358237
未发布 2016年我国能源行业大数据的发展现状及市场分析
by chenjunji123456 keys 分享 1470800539352
随着信息化的深入和两化的深度融合,大数据在石油石化行业应用的前景将越来越广阔。以下是是2016年我国能源行业大数据的发展现状及市场分析。
未发布 微盟游凤椿:私域实现企业与客户情感上的连接
by wx_16005 keys 分享 1612165104436
未发布 线下门店如何突围节日大促逆势翻盘?
by wx_16005 keys 分享 1625565609083
未发布 惊艳!10个复古风格的UI工具包(PSD)
by monkey keys 分享 1408347369889
众所周知,UI工具包对网页设计师的帮助是巨大的,它可以激发设计师的设计灵感,帮助他们更好的完成设计。前面慧都控件网已经跟大家分享了很多CSS和扁平化风格的UI工具包,今天跟大家分享点新鲜的,10个非常精美的复古风格的UI工具包,全部都有PSD文件可以下载。
Node.JS的表单提交及OnceIO中接受GET/POST数据的三种方法
by ourjs keys JS学习 JavaScript 1477923331417
在互联网上, QueryString是地址的一部分, 其中包含着需要传给后台的数据,通常以?开始,以&号分割。在表单提交时,会默认以QueryString的形式向后台发送数据,OnceIO会将其存储在res.query对象上。
未发布 跨平台开发框架DevExtreme发布v17.2.7|附下载
by AABBbaby keys 分享 1522810372359
DevExtreme Complete Subscription是性能最优的 HTML5,CSS 和 JavaScript 移动、Web开发框架,可以直接在Visual Studio集成开发环境,构建iOS,Android,Tizen和Windows Phone 8应用程序。DevExtreme包含 PhoneJS 和 ChartJS 两个原生UI组件,并且提供源代码。目前,DevExtreme支持VS2010/2012/2013集成开发环境,兼容Android 4+、iOS5+、Windows 8、Window Phone 8、Tizen五大移动平台,是Visual Studio开发人员开发跨平台移动产品的首选工具。
未发布 Qt VS MFC,谁才是你的最爱?(上)
by AABBbaby keys 分享 1459996441681

MFC(微软基础类库)是专门为windows设计的一个用于开发图形用户界面的类库。MFC或多或少使用了面向对象的方法包装了Win32的API,正因如此,这些API有时是C++,有时是C,甚至是C和C++的混合体。

Qt这个C++的图形库由Trolltech在1994年左右开发。它可以运行在Windows、Mac OSX、Unix、还有像Sharp Zaurus这类嵌入式系统中,Qt是完全面向对象的。Document/View modelMFC编程需要使用Document/View模式以及模板(template),如果不使用的话,编程将变得异常困难。而且模板(template)设定了固定的结构,若所需结构乃模板未定义的结构,则编程难。例如,划分一区域使显示两个视图(view)于两个文档(document)。还有一个经常的问题是:模板(template)创建了视图(view)却无法访问(access)它,文档(document)要做完所有事情,但是这经常会出现问题。 这种数据和视图分开的设计模式也是一种不错的模式,不应该成为否定MFC的理由。Qt不强制使用任何设计模式,如果你认为恰当,使用Document/view没有任何问题,不使用也没有任何问题。


 近期热门 - 点击最多
  1. React结合vite使用vue3,在纯typescript的react hooks中使用vue
  2. valtio基于Proxy代理比redux\zustand更简洁的react状态管理库
  3. React Native为http网络请求添加timeout超时异常处理: 用XMLHttpRequest替换fetch发送的区别
  4. React Native使用fetch发送http登陆验证请求失败:无法读取set-cookie并显示network request failed
  5. 克服Redux的缺点在React/Native中使用消息队列,pubsub-js更加简洁的组件间通信和状态传递方法
  6. Springboot+Gradle+Mysql+Jpa最简单实例教程
  7. SpringBoot+Spring6入门指南: 使用命令行快速搭建restful web api模板
  8. 如何通过 winax 的 ActiveXObject 或 Excel.Application 往 excel 中插入一张图片
  9. node.js用activex/com+自动化读写excel时查询接口、参数的调试方法
  10. TypeScript定义数字范围类型即仅包含【小时:分钟】的时间类型,每天指定时间点执行任务

  全端社区 - 最新回复
  1. valtio基于Proxy代理比redux\zustand更简洁的react状态管理库
  2. Windows与Mac通过git ssh和rsync实现文件共享互传
  3. Windows与Mac通过git ssh和scp实现文件共享互传
  4. React结合vite使用vue3,在纯typescript的react hooks中使用vue
  5. 使用PubSub-JS时ReactNative在后台运行一段时间唤醒后,组件无法scribe到publish的事件,typescript实现一个事件订阅发布组件
  6. React Native为http网络请求添加timeout超时异常处理: 用XMLHttpRequest替换fetch发送的区别
  7. ReactNative获取Android/iOS的MAC/IP地址: react-native-device-info模块的安装与使用
  8. React Native使用fetch发送http登陆验证请求失败:无法读取set-cookie并显示network request failed
  9. 克服Redux的缺点在React/Native中使用消息队列,pubsub-js更加简洁的组件间通信和状态传递方法
  10. Springboot+Gradle+Mysql+Jpa最简单实例教程

  开源的 OurJS
OurJS开源博客已经迁移到 OnceOA 平台。

  关注我们
扫一扫即可关注我们:
OnceJS

OnceOA