当前位置:网站首页>C # use smtpclient The sendasync method fails to send mail, and always returns canceled
C # use smtpclient The sendasync method fails to send mail, and always returns canceled
2022-07-04 09:34:00 【Dandelion_ drq】
problem :
call SmtpClient.SendAsync, stay SendCompleted The callback function of always gets e.Cancelled by true.
And then I tested it , Same code , Just put SmtpClient.SendAsync Change to SmtpClient.Send Method , Mail sent successfully .
reason :
Send... Before sending email SmtpClient The instance of is released . because SendAsync Is an asynchronous operation , After calling this method, you just push the email to SMTP The server , The sending operation has not been completed yet , When SmtpClient When the instance is released , It cancels any outstanding asynchronous operations , So this email was also cancelled . therefore , The right thing to do is to put SmtpClient The instance of is placed in SendCompleted And then release ,MailMessage Examples are the same , Otherwise it will be reported
System.Net.Mail.SmtpException: Failed to send email . —> System.ObjectDisposedException: The released object cannot be accessed .
Error of .
Reference resources :
边栏推荐
- 自动化的优点有哪些?
- C language - Introduction - Foundation - syntax - [operators, type conversion] (6)
- Review of last week's hot spots (6.27-7.3)
- Simulate EF dbcontext with MOQ - mocking EF dbcontext with MOQ
- Nurse level JDEC addition, deletion, modification and inspection exercise
- 2022-2028 global gasket plate heat exchanger industry research and trend analysis report
- 什么是权限?什么是角色?什么是用户?
- How to ensure the uniqueness of ID in distributed environment
- Write a jison parser (7/10) from scratch: the iterative development process of the parser generator 'parser generator'
- HMS core helps baby bus show high-quality children's digital content to global developers
猜你喜欢

Mantis creates users without password options

Nurse level JDEC addition, deletion, modification and inspection exercise

Target detection -- intensive reading of yolov3 paper

Daughter love: frequency spectrum analysis of a piece of music

How should PMP learning ideas be realized?
![C language - Introduction - Foundation - syntax - [main function, header file] (II)](/img/5a/c6a3c5cd8038d17c5b0ead2ad52764.png)
C language - Introduction - Foundation - syntax - [main function, header file] (II)

Some points needing attention in PMP learning

回复评论的sql

How to ensure the uniqueness of ID in distributed environment

You can see the employment prospects of PMP project management
随机推荐
Lauchpad X | 模式
C language - Introduction - Foundation - syntax - data type (4)
Global and Chinese markets of hemoglobin analyzers in care points 2022-2028: Research Report on technology, participants, trends, market size and share
Markdown syntax
Daughter love: frequency spectrum analysis of a piece of music
The 14th five year plan and investment risk analysis report of China's hydrogen fluoride industry 2022 ~ 2028
2022-2028 global edible probiotic raw material industry research and trend analysis report
China electronic grade sulfur trioxide Market Forecast and investment strategy report (2022 Edition)
法向量点云旋转
PMP registration process and precautions
What is uid? What is auth? What is a verifier?
165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
Nurse level JDEC addition, deletion, modification and inspection exercise
UML sequence diagram [easy to understand]
Global and Chinese trisodium bicarbonate operation mode and future development forecast report Ⓢ 2022 ~ 2027
Golang defer
How to display √ 2 on the command line terminal ̅? This is actually a blog's Unicode test article
pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.
Langage C - démarrer - base - syntaxe - [opérateur, conversion de type] (vi)
2022-2028 global special starch industry research and trend analysis report