pls i need a c# code for sending form to email - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › pls i need a c# code for sending form to email (985 Views)
1 Reply
| pls i need a c# code for sending form to email by himself(op): 4:30pm On Aug 02, 2007 |
Guys , pls i need a c# code for sending form to email, mine keeps giving a transport error b[/i] Help Please Thanks |
| Re: pls i need a c# code for sending form to email by ants(m): 10:01am On Aug 09, 2007 |
// Instantiate a new instance of MailMessage MailMessage mMailMessage = new MailMessage(); // Set the sender address of the mail message mMailMessage.From = new MailAddress(from); // Set the recepient address of the mail message mMailMessage.To.Add(new MailAddress(to)); // Check if the bcc value is null or an empty string if ((bcc != null) && (bcc != string.Empty)) { // Set the Bcc address of the mail message mMailMessage.Bcc.Add(new MailAddress(bcc)); } // Check if the cc value is null or an empty value if ((cc != null) && (cc != string.Empty)) { // Set the CC address of the mail message mMailMessage.CC.Add(new MailAddress(cc)); } // Set the subject of the mail message mMailMessage.Subject = subject; // Set the body of the mail message mMailMessage.Body = body; // Set the format of the mail message body as HTML mMailMessage.IsBodyHtml = true; // Set the priority of the mail message to normal mMailMessage.Priority = MailPriority.Normal; // Instantiate a new instance of SmtpClient SmtpClient mSmtpClient = new SmtpClient(); // Send the mail message mSmtpClient.Send(mMailMessage); u should be able to adjust this code to make it work but note these two things 1. this code is for .NET 2.0 and 2. make sure u include "using System.Net.Mail;" in the namespace thanks |
Programming A Web Form To Email • How Do I Connect A Form To Mysql Database • Php Form To Mail Problem • 2 • 3 • 4
I Want To Learn Java • Please Help !its Urgent • Unable To Upload Site Application Package (plesk 8.3 Window Os)