How to check asp.net email

I have a code in my asp.net that sends an email:

public void SendEmail(string message)
{
    var body = message;

    var email = new MailMessage(ConfigurationManager.AppSettings["SenderEmail"],
                            ConfigurationManager.AppSettings["RecipientEmail"],
                            "Email Test", body);

    var client = new SmtpClient();
    client.Host = Properties.Settings.Default.smtp;
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.Credentials = CredentialCache.DefaultNetworkCredentials;

    client.Send(email);
}

I want to know how to check this. Whether this is a unit test or an integration test, I really don't care. I do not want to scoff at it. I actually want to write a test that the letter is sent with the correct message.

Can anyone help me with this?

+5
source share
7 answers

Just create a folder called "maildrop" on your c: / drive and use the following in the Web.config file:

<mailSettings>
    <smtp deliveryMethod='SpecifiedPickupDirectory'>
        <specifiedPickupDirectory pickupDirectoryLocation="c:\maildrop" />
    </smtp>
</mailSettings>

Additional Information:

http://weblogs.asp.net/gunnarpeipman/archive/2010/05/27/asp-net-using-pickup-directory-for-outgoing-e-mails.aspx

+12

, ?

, , , , .

+2

, , . , , .

0

, , ( - asp.net, ), :

1: sdk

opt 2: - ( HTTP-

opt 3: pop3 client/cli/api

ref opt 3: http://www.codeproject.com/KB/IP/popapp.aspx

0

. 2 , , . .

EmailApprovals.Verify(mail)

, : http://www.youtube.com/watch?v=Sf16dPq2n3w

0

SMTP4Dev

http://smtp4dev.codeplex.com/

( , ). ...

By default, I think it will just work with your code unchanged, since it listens on your local host.

When sending emails you will get a good taskbar notification popup ... just click on the notification to see the actual contents of the email.

0
source

All Articles