sir
i have implemented the "Sending email message" try it out exercise on page 319.
It works well for âSpecifiedPickupDirectoryâ.But when i tried to send an email message through network it gives error message that "smtp exception was unhandled by the user code".
I am sending you my web.config file and Email page .
web.config
Code:
<?xml version="1.0"?>
<configuration>
<system.web>
<pages theme="DarkGrey">
<controls>
<add tagPrefix="Wrox" tagName="Banner" src="~/Controls/Banner.ascx" />
</controls>
</pages>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network"
from="arman <[email protected]>">
<network host="smtp.yahoo.com" />
</smtp>
</mailSettings>
</system.net>
</configuration>
code behind of email page
Code:
using System.Net.Mail;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class site_Demos_Email : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
MailMessage myMessage = new MailMessage();
myMessage.Subject = "Test Message";
myMessage.Body = "Hello world, from Planet Wrox";
myMessage.From = new MailAddress("[email protected]", "arman");
myMessage.To.Add(new MailAddress("[email protected]", "asjad"));
SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.Send(myMessage);
}
}
Please guide