crossvertise / ActionMailerNext

Fork of ActionMailer.Net, A easy to use library to generate emails with razor views
MIT License
42 stars 24 forks source link

Error with multiple deliveries and differents views #4

Open tokp opened 10 years ago

tokp commented 10 years ago

Hello, I've made a fork of this project to implement Amazon SES. I've used Mandrill implementation as base. I get error when I try send two different emails from same object. Example:

var emailService = new EmailController(); emailService.SendMailToUser(data).Deliver(); emailService.SendMailToAdmin(data).Deliver();

The error is in MailAttribute class, in SendGrid in lines 170: foreach (var view in mail.AlternateViews) { using (var reader = new StreamReader(view.ContentStream))

error: '(((System.Net.Mail.AttachmentBase)(view)).ContentStream)' threw an exception of type 'System.ObjectDisposedException'

The view.ContentStream is not readable in the second call (SendMailToAdmin) but it works flawlessly with de first call. I've searched in the code without result. I don't know the issue origin, the RazorEngine or ActionMailerNext.

Thanks in advance.

PD: My Amazon implementation can be found here: https://github.com/tokp/ActionMailerNext/tree/master/src/ActionMailerNext/Implementations/Amazon

AndrewHK commented 10 years ago

Hey, I will check into it and get back to you soon :)