Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion 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 October 6th, 2011, 06:56 AM
Authorized User
 
Join Date: Apr 2005
Posts: 71
Thanks: 23
Thanked 0 Times in 0 Posts
Default Email demo

Hi Imar hope you are well. I am having a problem sending email through the Email demo form. I have played about with it using many different settings – too many to mention. My code is as below and I have checked and got the smtp address of my mail server (as an IP address), a port number plus I was told that I will not need to pass in a login or password (even though I have tried it anyway).

The error I am getting is
Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.

My Code behind file.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;

publicpartialclassDemos_Email : BasePage
{
protectedvoid Page_Load(object sender, EventArgs e)
    {
MailMessage myMessage = newMailMessage();
            myMessage.Subject = "Text Message";
            myMessage.Body = "Hello World, from Planet Wrox";
            myMessage.From = newMailAddress("******@.net", "MarkH");
            myMessage.To.Add(newMailAddress("******@.net", "This should be the receivers name"));
SmtpClient mySmtpClient = newSmtpClient();
            mySmtpClient.Send(myMessage);
    }
}


My web.config



Code:
 
<?xmlversion="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
       <system.web>
    <pagestheme="Monochrome">
      <!--removed styleSheetTheme="Monochrome" it messed up DarkGrey.Css-->
      <controls>
        <addtagPrefix="Wrox"tagName="Banner"src="~/Controls/Banner.ascx" />
      </controls>
    </pages>  
              <compilationdebug="true"targetFramework="4.0"/>
       </system.web>

  <!--my code for email-->
  <system.net>
  <mailSettings>    
    <smtpdeliveryMethod="Network"from = "MarkH &lt;******@.net&gt;">
      <networkhost= "**.*.**.***"port="25"/>
    </smtp>
  </mailSettings>
</system.net>
  <!--my code for email-->

  </configuration>



Many Thanks
Mark
 
Old October 6th, 2011, 08:54 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Quote:
This mail server requires authentication when attempting to send to a non-local e-mail address.
Looks like you need to assign a user name and password, as explained on page 318.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old October 6th, 2011, 09:38 AM
Authorized User
 
Join Date: Apr 2005
Posts: 71
Thanks: 23
Thanked 0 Times in 0 Posts
Default

Hi Imar and thanks for your prompt reply. Sorry I should have included that i uploaded my web site via the Visual Studio copy option. Hope this is fine or should I ftp it.

Regards
Mark
 
Old October 6th, 2011, 12:47 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Mark,

The way you deploy doesn't matter. Take a look at my initial reply: you need to assign a user name and password in web.config as explained on page 318.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Structure Demo Elad Reznik BOOK: Beginning Microsoft Visual Basic 2010 1 October 5th, 2010 05:51 AM
Bug on demo site vsjc BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 2 October 30th, 2009 09:07 AM
Chapter 4, demo.controls benjii82 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 October 26th, 2009 03:20 PM
wrox web site demo yesil65 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 October 2nd, 2008 01:06 PM
Chapter 8, Meno Demo sjar BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 4 June 20th, 2006 10:01 AM





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