Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,577 members, 7,820,087 topics. Date: Tuesday, 07 May 2024 at 09:30 AM

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 (902 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)

Programming/fortran / Oracle Buys Sun / Pls Help A Newbie

(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. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.