Sunday, May 20, 2007

GoDaddy.com System.Net.Mail Solution

Here is the C# version of the GoDaddy.com ASP.NET 2.0 Send Mail by Moojjoo http://www.mmwebs.com

Web.Config
<?xml version="1.0"?>

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>

<customErrors mode="Off"/>
<compilation debug="true"/> <!-- Be sure to change this to false when going to production -->

</system.web>
<system.net>

<mailSettings>
<smtp>

<network

host="relay-hosting.secureserver.net" />
</smtp>

</mailSettings>
</system.net>

</configuration>



.cs code behind for your .aspx page

protected void btnSubmit_Click(object sender, EventArgs e)
{

MailMessage myMail = new MailMessage();

myMail.From = new MailAddress("from@yourdomain.com");
myMail.Subject = "Contact Form";

MailAddressCollection myMailTo = new MailAddressCollection();
myMail.To.Add("to@domain.com");

StringBuilder sb = new StringBuilder();
sb.Append("Last Name: " + txtFirstName.Text + "<br>");

sb.Append("First Name: " + txtFirstName.Text + "<br>");
sb.Append("Address: " + txtAddress.Text + "<br>");

sb.Append("City: " + txtCity.Text + "<br>");
sb.Append("State: " + ddlState.SelectedValue + "<br>");

sb.Append("Zip: " + txtZip.Text + "<br>");
sb.Append("Email: " + txtEmail.Text + "<br>");

sb.Append("Questions/Comments: " + txtQandC.Text + "<br>");string strBody = sb.ToString();
myMail.Body = strBody;

myMail.IsBodyHtml = true;

SmtpClient smtp = new SmtpClient();
smtp.Credentials = CredentialCache.DefaultNetworkCredentials;

try

{

smtp.Send(myMail);

myMail = null;
}

catch (System.Exception ex)
{

Response.Write(ex.Message);

}

}

Moojjoo Õ¿Õ

http://www.mmwebs.com

http://www.autoinventoryonline.com/

4 comments:

Anonymous said...

Very nicely done. This was very helpful. I was trying to find this solution while I was on hold with Godaddy. I told the agent about it and it was new news to him. Once again, very helpful, THANK YOU!

Anonymous said...

Thank you so much! I have been searching for a solution all week, and wanted to throw in the towel, then stumbled upon your posting. Thank you!

-Joseph Marinaccio
Marinaccio Family Design

Anonymous said...

Can anyone recommend the best IT automation system for a small IT service company like mine? Does anyone use Kaseya.com or GFI.com? How do they compare to these guys I found recently: N-able N-central network health tool
? What is your best take in cost vs performance among those three? I need a good advice please... Thanks in advance!

Anonymous said...

Thank You

How to Install Linux on Legacy BIOS Systems

How to Install Linux on Legacy BIOS Systems Understanding Legacy BIOS Systems What is Legacy BIOS? Legacy BIOS, short for Basic Inp...