by-expession

Expression Web Resources

Portfolio Starter Kit: sending email

Latest post 12-29-2006 5:19 PM by cdwise. 0 replies.
  • 12-29-2006 5:19 PM

    • cdwise
    • Top 10 Contributor
    • Joined on 12-22-2006
    • Houston, TX
    • Posts 540

    Portfolio Starter Kit: sending email

    So far I have tried to use the contact.aspx and contact.cs pages from the Portfolio Starter kit on three different web hosts and the contact.cs and web.config files do not work even after the necessary modificaitons to send to the correct mail server using valid credentials. The site I am using to test Expression Web material at is hosted on GoDaddy.com

    The following code modified to match your godaddy.com hosted domain is what powers the http://custom1.expressiondesigns.com/contact.aspx site. This code behaves a bit differently from the code Microsoft provided. With it the person who fills out the form gets a confirmation email whilethe email account you designate in the bcc field is the address you want to receive the email on your end.

    The "Title" field becomes the subject contains the form sender, their email, message and when it was sent. Here is the code.


    using System;
    using System.Web.Mail;
    using System.Configuration;

    public partial class Contact : System.Web.UI.Page

     protected void btnSend_Click(object sender, EventArgs e)
     {
        const string SERVER = "relay-hosting.secureserver.net";
        MailMessage oMail = new System.Web.Mail.MailMessage();
        oMail.From = "email@domain.tld";
        oMail.To = this.Name.Text + "<" + this.Email.Text + ">";
        oMail.Bcc = "recipient@domain.tld";
        oMail.Subject = this.TitleType.Text;
        oMail.BodyFormat = MailFormat.Html; // enumeration
        oMail.Body = "<p>From: " + this.Name.Text + "<br>" + this.Email.Text + "</p><p>" + this.Message.Text + "</p>" + "Sent at: " + DateTime.Now ;
        SmtpMail.SmtpServer = SERVER;
        SmtpMail.Send(oMail);
        oMail = null; // free up resources
       
        EmailViewControl.ActiveViewIndex = 1;
     }
    }

     

    Cheryl D Wise MS MVP Expression Instructor: starttoweb.com

    Filed under:
Page 1 of 1 (1 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems Sponsored by: Start to Web
@ 2005-2008 Cheryl D Wise