This section of my website is dedicated to random topics. Information here could contain anything from scripts, programs, instructions, etc. I added this section to my website because I ran into simple problems that hendered the production of my project and I assume that others might have the same fate. For example: Figuring out how to find the file path in C# on a remote server where you uploaded your website. If I can help at least one person find information that they are looking for, then I will feel as if I contributed to my community of developers.
Sql Server Cities and States Tables
If your developing a project that requires a database that has cities and states with a relationship between the two
then you can download it below. I could not find this if my life depended on it so after I created it I decided that I should share it with
the world so here it is. Please leave a comment or email me if you have any concerns or question.
Note: The easiest way to add these tables to your database is to use Microsoft SQL Server Managment Studio: Right Clicking on the database you wish to add the tables to, Select Task, Select Import Data (When the Import Wizard ask for the destination select Microsoft Excel because the data is in an excel format) and follow the directions. Again if you have any question contact me. Enjoy!!!
Sending email using C#
This is actually pretty simple using the System.Net and System.Net.Mail namespaces of .Net. Here is the code.
1: using System.Net.Mail;
2: using System.Net;
4: protected void contactButton_Click(object sender, EventArgs e)
6: //Create an instance of the MailMessage class
7: MailMessage msg = new MailMessage();
9: //Set the properties
10: msg.To.Add(new MailAddress("your email here", "subject goes here"));
11: msg.From = new MailAddress("your email here", "display name here");
13: msg.Subject = "subject goes here";
15: msg.Body = "message goes here";
16: msg.IsBodyHtml = false;
17: msg.Priority = MailPriority.High;
19: SmtpClient c = new SmtpClient("your outgoing mail server here");
20: NetworkCredential cred = new NetworkCredential("your username
for the email account", "your password for the email
22: c.Credentials = cred;
23: c.EnableSsl = true;
Note: A couple of things to be noted. Credentials and EnableSsl are not required but are specific to which service you are using. For example my hosting service (godaddy.com) requires me to have my Credentials but does not allow Ssl to be enabled.