Email To Disk Error
See original GitHub issueI am using a very basic version with the call:
var email = Email .From("support@myemail.com") .To("support@myemail.com") .Subject("Errors founds in " + _context.LocationName) .Body(strMyText, false).Send();
This is my setup in my Startup.cs file:
services.AddFluentEmail("support@bear.systems").AddSmtpSender("localhost", 25);
Whenever I send the file, I am getting the following error:
The specified path is invalid : '\\2018-11-29_09-17-50_163' at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle) at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at FluentEmail.Core.Defaults.SaveToDiskSender.SaveEmailToDisk(IFluentEmail email) at FluentEmail.Core.Defaults.SaveToDiskSender.SendAsync(IFluentEmail email, Nullable
1 token)
at FluentEmail.Core.Defaults.SaveToDiskSender.Send(IFluentEmail email, Nullable1 token) at FluentEmail.Core.Email.Send(Nullable
1 token)`
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:13
Top GitHub Comments
Just don’t use static class “Email” on your controler, but use an instance of “IFluentEmail” via DI.
Then use
await emailService .To(recipient, “bob”) .Subject(“hows it going bob”) .Body(“yo bob, long time no see!”) .SendAsync();
And it will work 😃
I figured it out - I added the follwoing:
Email.DefaultSender = new SmtpSender(new System.Net.Mail.SmtpClient() { Host = “localhost”, Port = 25 });