.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

EmailSending

Posted By: Aamrapali Tamgadge     Posted Date: January 24, 2011    Points:2   Category :ASP.Net
Hi..ME having one Enqury form..when i click on submit button i want to send the enquiry msg to the respected email address..How can i do this m litte bit confuse if any user sened enquiry den how to pass server or domain address values..please anyone help me out.


Responses
Author: srini             
Posted Date: January 24, 2011     Points: 5   

Hi,

I cant understand your question?

Regards,
Srini

Srini
Author: Vikramraj             
Posted Date: January 24, 2011     Points: 5   

hi,
you can use following code
use namespace as "System.Net.Mail"

protected void btnSendmail_Click(object sender, EventArgs e)
{

SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();

try
{
MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);

smtpClient.Host = "localhost";

smtpClient.Port = 25; // Add port no

message.From = fromAddress;

message.To.Add("admin1@yoursite.com");
message.Subject = "Feedback";

message.CC.Add("admin1@yoursite.com");
message.CC.Add("admin2@yoursite.com");

message.Bcc.Add(new MailAddress("admin3@yoursite.com"));
message.Bcc.Add(new MailAddress("admin4@yoursite.com"));

message.IsBodyHtml = false;

message.Body = txtMessage.Text;

smtpClient.Send(message);

lblStatus.Text = "Email successfully sent.";
}
catch (Exception ex)
{
lblStatus.Text = "An exception has occurred while sending mail." + ex.Message;
}

I hope this code will work as per your requirment
with regards
Vikramraj

Author: Aamrapali Tamgadge             
Posted Date: January 24, 2011     Points: 5   

Hi..Vikramraj..but if i want to publish this email sending demo online..Through smtp server not as a client then how can i use port no only plese suggest me how it wil work wen it is on server


Software Programmer At OTIS ISRC
Author: Aamrapali Tamgadge             
Posted Date: January 24, 2011     Points: 5   

if i wil change the port no is den it wil work?

Software Programmer At OTIS ISRC
Author: Aamrapali Tamgadge             
Posted Date: January 24, 2011     Points: 5   

Hi..Srini..Simply der is der is a website where the students will fill the enquiry form to take the enqury of any related class timing or batches information.den this enquiry msg i want to send to another emailid aamrapali@globalinfobase.com how can i do this..

Software Programmer At OTIS ISRC


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend