₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,329,109 members, 8,438,843 topics. Date: Saturday, 04 July 2026 at 05:59 AM

Toggle theme

pls i need a c# code for sending form to email - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingpls 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
1 Reply

Programming A Web Form To EmailHow Do I Connect A Form To Mysql DatabasePhp Form To Mail Problem234

I Want To Learn JavaPlease Help !its UrgentUnable To Upload Site Application Package (plesk 8.3 Window Os)