Sign In  Sign Up Live-Chat

Utilizing mailSettings config section?

Last post 03-02-2006, 8:31 AM by digitalman. 3 replies.
Sort Posts: Previous Next
  •  02-14-2006, 12:56 PM 41657

    Utilizing mailSettings config section?

    I have an asp.net 2.0 app which uses membership and already has the smtp mailSettings section in the web.config file. I'd like to be able to use this to get the host info for creating the Aspose SmtpClient object. Has anyone done this? Is there an easy way to read the host info out of that config section and pass it to the Smtp object?


     
  •  02-28-2006, 6:43 PM 42898 in reply to 41657

    Re: Utilizing mailSettings config section?

    Hi, thanks for considering Aspose.Network.

    Our development team is working on this issue. We will provide some solutions ASAP.

    Thanks for your patience.


    Team Lead
    Aspose Guangzhou Team
    About Us

    Contact Us
     
  •  03-02-2006, 8:29 AM 43058 in reply to 42898

    Re: Utilizing mailSettings config section?

    Hi, digitalman,

    Thanks for your considering aspose.network.

    The issue about using the mailsetting section in the web.config file is studied carefully by our developers. Because of the feature is supported only in .net 2.0 and the aspose.network is still based on .net 1.1, it is a little bit difficult to support that features at present.

    However, we will have some plans to port the aspose.network to pure .net 2.0 and integrate with more features of .net 2.0.

    We have created some samples code for you, and feel free to use it according to your needs. If you have any problems, we are more than glad to provide any helps or sample codes.

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SmtpSection smtpSec = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp");     
            Response.Write(smtpSec.Network.Host + "\r\n");
            Response.Write(smtpSec.Network.UserName + "\r\n");
            Response.Write(smtpSec.Network.Password + "\r\n");
            Response.Write(smtpSec.Network.Port + "\r\n");
           
            //initialize the mailmessage class
            SmtpConnection conn = new SmtpConnection(smtpSec.Network.Host, smtpSec.Network.Port, smtpSec.Password, smtpSec.Password);
            //create MailMessages
            MailMessage msg = new MailMessage(smtpSec.From, "yourname@aspose.com", "hello", "hello mailSettings");
            msg.SendAsync(conn);
        }
    }

    Web.Config file as following
    <?xml version="1.0"?>
    <configuration>
        <system.net>
            <mailSettings>
                <smtp deliveryMethod="Network" from="network@aspose.com">
                    <network host="localhost" port="25" userName="youraccount" password="yourpassword"/>
                </smtp>
            </mailSettings>
        </system.net>
        ...

    Team Lead
    Aspose Guangzhou Team
    About Us

    Contact Us
     
  •  03-02-2006, 8:31 AM 43059 in reply to 43058

    Re: Utilizing mailSettings config section?

    That's perfect! Exactly what I was looking for. Thanks.
     
View as RSS news feed in XML