-6

What library i need for IEmailSender in asp.net mvc 5 ?

This is how code looks like:

public class PasswordResetHelper
{
     private IEmailSender emailSender;    
    public PasswordResetHelper(IEmailSender emailSenderParam) 
    {        
        emailSender = emailSenderParam;    
    }    
    public void ResetPassword() 
    {        
        // ...call interface methods to configure e-mail details... 
        emailSender.SendEmail();    
    } 
}

I take that code from a book for mvc 5 but it didn't work. What i do wrong ?

P.S. Sorry for bad english.

Ursaciuc Adrian
  • 37
  • 1
  • 2
  • 10

1 Answers1

0

You seem to be looking for a piece of code that will send emails for you. This isn't in that book.

The code you show is in a chapter that's titled "Building Loosely Coupled Components":

[...] one of [the] most important features of the MVC pattern is that it enables separation of concerns. [...] A simple example will help put things in context. If we were writing a component called MyEmailSender to send e-mail messages [...]

Emphasis mine.

They're trying to teach you the concept of building good, maintainable, testable software through separation of concerns and dependency injection.

If you're just looking for copy-pasteable code to implement an email sending class, you've bought the wrong book.

If all you're looking for is code to send an email, see How to send email in ASP.NET C#.

Community
  • 1
  • 1
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • I don't look for copy-pastebale code, I just want to see how that code work and i understand more easy if i try it not just read it – Ursaciuc Adrian Jul 31 '15 at 12:52
  • There is no code. The implementation of `MyEmailSender` is not in the book. They're trying to explain a concept. – CodeCaster Jul 31 '15 at 12:53