Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,199,619 members, 7,972,285 topics. Date: Friday, 11 October 2024 at 08:13 AM |
Nairaland Forum / Science/Technology / Programming / pls i need a c# code for sending form to email (929 Views)
Programming A Web Form To Email / How Do I Connect A Form To Mysql Database / Php Form To Mail Problem (2) (3) (4)
(1) (Reply)
pls i need a c# code for sending form to email by himself(m): 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)
I Need Help With Arrays In C / I Need An Advise / What Program To Learn
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9 |