Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 6th, 2007, 03:37 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

In your web.config,

You stated you had:

   <smtp deliveryMethod="PickupDirectoryFromIis" from="[email protected]">

Try changing the deliveryMethod to Network. Let us know if that helped? I will check out my own source when I come home, and post my settings here. I've successfully managed to send mails on user registration etc. Does that work for you, or does that also fail?

Cheers,

Peter


http://entropia-online.blogspot.com/
 
Old September 7th, 2007, 08:58 AM
rav rav is offline
Authorized User
 
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Peter
I was not getting any errors when I usewd "PickupDirectoryFromIis" as the delivery method...
I was getting errors when I was using Network in web.config file...from starting

I am not able to receive email with any of the above delivery method..

rav

 
Old September 7th, 2007, 01:37 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

Rav,

My web.config:

  <system.net>
    <mailSettings>
      <smtp from="[email protected]" deliveryMethod="Network" >
        <network host="localhost" password="" userName="" />
      </smtp>
    </mailSettings>
  </system.net>
</configuration>

  <EO defaultConnectionStringName="LocalSqlServer">
    <contactForm mailTo="[email protected]"/>
  </EO>

Also, does the click event in your ASPX pagge refer to the same name as in your code-behind file?

My button:

<asp:Button runat="server" ID="txtSubmit" Text="Send" OnClick="txtSubmit_Click" />

My click event in the code-behind:

        protected void txtSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            // Composed and send a mail
            MailMessage msg = new MailMessage();
            msg.IsBodyHtml = false;
            msg.From = new MailAddress(txtEmail.Text, txtName.Text);
            msg.To.Add(new MailAddress(Globals.Settings.ContactForm.MailTo));

            if (!string.IsNullOrEmpty(Globals.Settings.ContactFor m.MailCC))
            msg.CC.Add(new MailAddress(Globals.Settings.ContactForm.MailCC));

            msg.Subject = string.Format(Globals.Settings.ContactForm.MailSub ject, txtSubject.Text);

            msg.Body = txtBody.Text;

            new SmtpClient().Send(msg);

            // Confirm, and empty the page
            lblFeedbackOK.Visible = true;
            lblFeedbackKO.Visible = false;
            txtName.Text = "";
            txtEmail.Text = "";
            txtSubject.Text = "";
            txtBody.Text = "";
        }

        catch (Exception)
        {
            lblFeedbackOK.Visible = false;
            lblFeedbackKO.Visible = true;
        }
    }

Could you post both your aspx and code-behind for the contact page? Perhaps that will help us troubleshoot your problem.

Thanks :)

Cheers,

Peter

http://entropia-online.blogspot.com/
 
Old September 7th, 2007, 08:39 PM
rav rav is offline
Authorized User
 
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Peter

Below is the code behind and aspx for contact...I think thats correct and I have also checked my config file which has the same settings as yours...

protected void btnSubmit_Click(object sender, EventArgs e)
{
   try
   {
      MailMessage msg = new MailMessage();
      msg.IsBodyHtml = false;
      msg.From = new MailAddress(txtEmail.Text, txtName.Text);
      msg.To.Add(new MailAddress(Globals.Settings.ContactForm.MailTo));
      if (!string.IsNullOrEmpty(Globals.Settings.ContactFor m.MailCC))
        msg.CC.Add(new MailAddress(Globals.Settings.ContactForm.MailCC));
      msg.Subject = string.Format(Globals.Settings.ContactForm.MailSub ject, txtSubject.Text);
      msg.Body = txtBody.Text;
      new SmtpClient().Send(msg);

      lblFeedbackOK.Visible = true;
      lblFeedbackKO.Visible = false;
      txtName.Text = "";
      txtEmail.Text = "";
      txtSubject.Text = "";
      txtBody.Text = "";
   }
   catch (Exception ep)
   {
      lblFeedbackOK.Visible = false;
      lblFeedbackKO.Visible = true;
      lblFeedbackKO.Text = lblFeedbackKO.Text +" "+ ep.Message;
   }
}


=========

<table cellpadding="2">
  <tr>
    <td style="width: 120px;" class="fieldname">
      <asp:Label runat="server" ID="lblName" AssociatedControlID="txtName" Text="Your name:" />
    </td>
    <td style="width: 400px;">
      <asp:TextBox runat="server" ID="txtName" Width="100%" />
    </td>
    <td style="width: 55px">
      <asp:RequiredFieldValidator runat="server" Display="dynamic" ID="valRequireName" SetFocusOnError="true" ControlToValidate="txtName" ErrorMessage="Your name is required">*</asp:RequiredFieldValidator>
    </td>
  </tr>

  <tr>
    <td class="fieldname" style="width: 120px">
      <asp:Label runat="server" ID="lblEmail" AssociatedControlID="txtEmail" Text="Your e-mail:" />
    </td>
    <td>
      <asp:TextBox runat="server" ID="txtEmail" Width="100%" />
    </td>
    <td style="width: 55px">
      <asp:RequiredFieldValidator runat="server" Display="dynamic" ID="valRequireEmail" SetFocusOnError="true" ControlToValidate="txtEmail" ErrorMessage="Your e-mail address is required">*</asp:RequiredFieldValidator>
      <asp:RegularExpressionValidator runat="server" Display="dynamic" ID="valEmailPattern" SetFocusOnError="true" ControlToValidate="txtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ErrorMessage="The e-mail address you specified is not well-formed">*</asp:RegularExpressionValidator>
    </td>
  </tr>

  <tr>
    <td class="fieldname" style="width: 120px">
      <asp:Label runat="server" ID="lblSubject" AssociatedControlID="txtSubject" Text="Subject:" />
    </td>
    <td>
      <asp:TextBox runat="server" ID="txtSubject" width="100%" />
    </td>
    <td style="width: 55px">
      <asp:RequiredFieldValidator runat="server" Display="dynamic" ID="valRequireSubject" SetFocusOnError="true" ControlToValidate="txtSubject" ErrorMessage="The subject is required">*</asp:RequiredFieldValidator>
    </td>
  </tr>

  <tr>
    <td class="fieldname" style="width: 120px; height: 138px;">
      <asp:Label runat="server" ID="lblBody" AssociatedControlID="txtBody" Text="Body:" />
    </td>
    <td style="height: 138px">
      <asp:TextBox runat="server" ID="txtBody" Width="100%" TextMode="MultiLine" Rows="8" />
    </td>
    <td style="width: 55px; height: 138px">
      <asp:RequiredFieldValidator runat="server" Display="dynamic" ID="valRequireBody" SetFocusOnError="true" ControlToValidate="txtBody" ErrorMessage="The body is required">*</asp:RequiredFieldValidator>
    </td>
  </tr>

  <tr>
    <td colspan="3" style="text-align: right; height: 61px;">
      <asp:Label runat="server" ID="lblFeedbackOK" Text="Your message has been successfully sent." SkinID="FeedbackOK" Visible="false" />
      <asp:Label runat="server" ID="lblFeedbackKO" Text="Sorry, there was a problem sending your message." SkinID="FeedbackKO" Visible="false" />
      <asp:Button runat="server" ID="txtSubmit" Text="Send" OnClick="btnSubmit_Click" />
      <asp:ValidationSummary runat="server" ID="valSummary" ShowSummary="false" ShowMessageBox="true" />
    </td>
 </tr>
</table>

Thanks
rav

 
Old September 11th, 2007, 01:59 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

Rav,

do you still get an error if you use the "Network" setting instead of the IISFolder one?



http://entropia-online.blogspot.com/
 
Old September 11th, 2007, 10:50 AM
rav rav is offline
Authorized User
 
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't get any errors or exceptions now with Network as the delivery method.
Eamil seems to go as my another label shows up with the message the my email is sent and all the feilds clears up after the eamil is gone but unable to receive email in any of my yahoo or gmail accounts.
thanks
rav

 
Old September 11th, 2007, 11:11 AM
rav rav is offline
Authorized User
 
Join Date: Feb 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I do not errors after setting up relay access to SMTP for 127.0.0.1...Thanks Peter for your blog..
Here is my web.config file
<TheWebHouse defaultConnectionStringName="LocalSqlServer">
   <contactForm mailTo="[email protected]"/>
</TheWebHouse>

<system.net>
  <mailSettings>
     <smtp from="[email protected]" deliveryMethod="Network">
    <network host="localhost" userName="" password="" port="25"/>
     </smtp>
  </mailSettings>
</system.net>







Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET E-Commerce Prog Problem - Design - gapoce All Other Wrox Books 42 February 9th, 2011 03:06 AM
Difference between ASP.NET programmer v/s C# prog myquery General .NET 1 October 20th, 2007 06:43 AM
ERROR using ASP.net Web Site Administration Tool erictamlam ASP.NET 2.0 Basics 0 April 5th, 2007 02:52 AM
ERROR using ASP.net Web Site Administration Tool erictamlam C# 2005 0 April 3rd, 2007 01:28 AM
ASP.NET E-Commerce Prog Problem - Design -Solution cat2123 All Other Wrox Books 1 December 29th, 2003 06:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.