One of the streams has already been used and can't be reset to the origin.

 

在透過C# SMTP API寄發信件通知時候
若有附件
這時候若處裡不當
就可能拋出這個例外錯誤



Before

由於例外發生在
Attachment只要SMTP使用完後做Dispose也會連動將MemoryStream給清空
因此應放置於迴圈內每次初始


After





Ref:
SMTPException One of the streams has already been used and can't be reset to the origin




留言

這個網誌中的熱門文章

經得起原始碼資安弱點掃描的程式設計習慣培養(五)_Missing HSTS Header

經得起原始碼資安弱點掃描的程式設計習慣培養(三)_7.Cross Site Scripting(XSS)_Stored XSS_Reflected XSS All Clients

(2021年度)駕訓學科筆試準備題庫歸納分析_法規是非題