首页 \ 问答 \ 用SMTPClient检查邮件是否在VB.NET中成功发送(Check if mail was successfully sent in VB.NET with SMTPClient)

用SMTPClient检查邮件是否在VB.NET中成功发送(Check if mail was successfully sent in VB.NET with SMTPClient)

我正在尝试创建一个将电子邮件发送到smtp服务器的应用程序。

服务器未设置为固定,但会根据电子邮件应发送到的电子邮件地址的域部分进行查找。

例:

发邮件至:test@stackoverflow.com

域部分:stackoverflow.com

MX记录查找的结果(命令行“nslookup -type = mx stackoverflow.com”:

MX首选项= 30,邮件交换器= stackoverflow.com.sgb.compsoverflow.com MX首选项= 40,邮件交换器= stackoverflow.com.s9b2.psmtp.com stackoverflow.com MX首选项= 10,邮件交换器MX preference = 20,邮件交换器= stackoverflow.com.s9a2.psmtp.com

知道邮件服务器是否接受邮件并且邮件已成功发送将非常有用。

到目前为止,我能够通过使用System.Net.Mail.SMTPClient对象及其SendAsync函数获取SMTP-Server错误代码(如果发生错误(StatusCode 5xx)),那么,如果有错误,我在SMTPClient的回调事件中获得一个Exception-Object

我很清楚,并非每个邮件服务器都会告诉我mailaccount是否真正存在,然后用错误代码拒绝我的邮件,而只是接受邮件并删除邮件。 因此,我会很感激另一种方法来检查邮件是否被发送(注意:没有阅读,这将是阅读确认)

最终目的是:尝试使用域名mailserver向收件人发送电子邮件,如果失败,请根据错误代码(用户不存在 - > abort / mailserver未响应 - >使用另一个邮件服务器(如果可用))继续操作。

预先感谢(并对错别字:)))


I'm trying to create an application that sends an email to an smtp-server.

The server is not set fixed, but will be looked up according to the domainpart of the email-address where the email should be sent to.

Example:

Email To: test@stackoverflow.com

Domain-Part: stackoverflow.com

Result of a MX-Record Lookup (commandline "nslookup -type=mx stackoverflow.com":

stackoverflow.com MX preference = 30, mail exchanger = stackoverflow.com.s9b1.psmtp.com stackoverflow.com MX preference = 40, mail exchanger = stackoverflow.com.s9b2.psmtp.com stackoverflow.com MX preference = 10, mail exchanger = stackoverflow.com.s9a1.psmtp.com stackoverflow.com MX preference = 20, mail exchanger = stackoverflow.com.s9a2.psmtp.com

It would be quite useful, to know if the message was accepted by the mailserver and the message was successfully sent.

What I am able so far is, that I can get the SMTP-Server error code (if there was an error (StatusCode 5xx) by using the System.Net.Mail.SMTPClient Object and its SendAsync Function. There, if there was an error, I get an Exception-Object in the Callback-Event of the SMTPClient

I'm well aware that not every mailserver will tell me if the mailaccount truly exists and then reject my mail with an errorcode but instead just accept the message and then delete it. Therefore I would be grateful for another Method to check if the mail was sent (note: not read, that would be the read confirmation)

The final purpose would be: Try to send an email to a recipient using it's domains mailserver and if it fails, proceed according to the errorcode (user does not exist -> abort / mailserver did not respond -> use another mailserver if available).

Thanks in advance (and sorry for typos :))


原文:https://stackoverflow.com/questions/6679766
更新时间:2023-05-23 18:05

最满意答案

定义一个新的方法来推送你的详细视图控制器,并使用-performSelectorOnMainThread:withObject:waitUntilDone:在主线程上执行它。 不要尝试从其他线程进行任何UI更改。


Define a new method to push your detail view controller and use -performSelectorOnMainThread:withObject:waitUntilDone: to perform it on the main thread. Don't try to make any UI changes from other threads.

相关问答

更多
  • 尝试这个: FIRAuth.auth()?.sendPasswordResetWithEmail(userEnteredEmail!, completion: { error in dispatch_async(dispatch_get_main_queue(), { if error != nil { //Tell user that the user name or password is incorrect. let errorCode = error!.code ...
  • 定义一个新的方法来推送你的详细视图控制器,并使用-performSelectorOnMainThread:withObject:waitUntilDone:在主线程上执行它。 不要尝试从其他线程进行任何UI更改。 Define a new method to push your detail view controller and use -performSelectorOnMainThread:withObject:waitUntilDone: to perform it on the main thre ...
  • 使用dispatch_async ,该位代码不会阻塞。 这意味着在fetchedData之前触发了数组计数日志语句,因此您的字典和数组仍为空。 查看日志语句的顺序 - 在记录字典之前应该看到数组计数。 // Executes on another thread. ViewDidLoad will continue to run. dispatch_async(kBgAdsQueue, ^{ NSData *data = [NSData dataWithContentsOfURL:url]; ...
  • 最简洁的答案是不。 DynamoDB是一个无模式存储。 在读取期间:如果客户端的AWSDynamoDBObjectModel具有比AWSDynamoDBObjectModel中的属性更多的属性,反之亦然,则会忽略额外的属性。 写入期间:这里记录了4种不同的保存行为选项。 默认的AWSDynamoDBObjectMapperSaveBehaviorUpdate会使未建模的属性不受影响,并且对于您的用例应该可以正常工作。 The short answer is, no. DynamoDB is a schema ...
  • 根据文件 : - (void)addAnimation:(CAAnimation *)anim forKey:(NSString *)key 将动画对象添加到接收器的渲染树中以获取指定的键。 参数anim : 要添加到渲染树的动画。 请注意,对象由渲染树复制,未引用。 对对象的任何后续修改都不会传播到渲染树中。 所以我认为重用相同的CAAnimation对象是安全的。 According to the docs: - (void)addAnimation:(CAAnimation *)anim forKey ...
  • 我没有在iOS 6上使用过两个NSPersistentStoreCoordinators ,但在WWDC期间明确提到了来自不同商店协调员的上下文之间的合并更改,因此我认为它在iOS 7中已更改。请参阅以下会话: 207 - Core核心数据有什么新功能(从幻灯片编号145开始)。 211 - 核心数据性能(从幻灯片编号91开始), I haven't been using two NSPersistentStoreCoordinators on iOS 6, but merging changes betw ...
  • 除了@lassevk建议的两阶段过程之外,您还可以使用管道结构将命令“推送”到渲染器,以便这些更改获取渲染引擎的另一个工作项的形式。 例如,假设您的引擎遵循如下工作流程: 计算职位 过程物理 过程灯过程摄像头 渲染场景 您可以将新项目添加到位置0中的工作流程中,称为“过程更改”,它从管道中提取信息并将其合并到场景中。 In addition to the two-stage process suggested by @lassevk you could use a Pipe structure to "pu ...
  • 不确定你正在使用哪个实现,但是我无法获得无限循环,只是取消注释表达式。 (我使用了几个R6RS实现,包括Racket。) 为了简化操作,我删除了你的代码: #!r6rs (import (rnrs)) (define (print . args) (for-each display args) (newline)) (let ((spawn-thread (lambda (it . args) (call/cc (apply it args)))) (main ...
  • 到目前为止,评论和答案中存在相当大的混淆。 STA或MTA是线程的属性。 但重要的是COM组件需要什么。 这是在ThreadingModel注册表值中声明的。 你找到了“公寓”,这是一个非常常见的环境。 这意味着该组件不支持线程。 这与.NET框架中的绝大多数类没有什么不同,很少有线程安全的。 最大的区别是COM 强制执行线程安全。 使用.NET类,您可以编写代码,以便以线程安全的方式使用类对象。 这很难做到正确并且是一个非常难以诊断的错误来源,但设计良好的锁定可以让你绕过限制。 这是不可能的COM,它将始 ...
  • 您应该在主线程上执行GUI相关任务,在要更新textview值的代码周围添加主队列/线程块。 ispatch_queue_t que = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(que, ^{ thisRiverGauge = [[RiverGauge alloc] initWithStationInfo:gauge forHistoryInHours:5 inThisFormat:@ ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。