イメージを暗号化しました。 これでイメージを読み取り、電子メールに添付して解読する必要があります。イメージファイルをMemoryStreamに挿入して電子メールに添付する方法
最初のステップでは、イメージファイルを入れて電子メール に添付しようとしましたが、電子メールを受信すると、添付イメージが破損しています。
私はさまざまな方法を試していますが、成功することはありません。 (私はテスト用のWindowsアプリケーションプロジェクトを作成し、最終的に私はMVC Webアプリケーションプロジェクトでソリューションを使用する必要があります)
private void btnSend_Click(object sender, EventArgs e)
{
var filePath = "D:\\3.jpg"; // path to none encrypted image file
var ms = new MemoryStream(File.ReadAllBytes(filePath));
// Create attachment
var attach = new Attachment(ms, new ContentType(MediaTypeNames.Image.Jpeg));
attach.ContentDisposition.FileName = "sample.jpg";
// Send Email
IMailSender mailSender = new MailSender();
var isSuccess = mailSender.Send(
"sample email title",
"[email protected]",
"sample subject",
"sample body",
new Attachment[] { attach });
MessageBox.Show(isSuccess ? "Email sent successfully" : mailSender.ErrorMessage);
}
を役に立てば幸い正しいポジションを探しますか? ms.Seek(0、SeekOrigin.Begin);あなたの助けをいただきありがとうございます。 – Digvijay