Subscribe to Subscribers

Forums » .NET » .NET »

Hi I have written small code for sending mail using smtp server in ASP.NET With C# Using


Posted Date: 18 Nov 2009      Posted By:: durga     Member Level: Bronze    Member Rank: 4130     Points: 1   Responses: 4



Hi

I have written small code for sending mail using smtp server in ASP.NET With C#
Using my code mail is going with in company only.outside domains(gmail,yahoo...)it is not going..
Any option to sending mail to outside domains also?


here i attached my code

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

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

// You can specify the host name or ipaddress of your server
// Default in IIS will be localhost
smtpClient.Host = d;

//Default port will be 25
smtpClient.Port = 25;

//From address will be given as a MailAddress Object
message.From = fromAddress;

// To address collection of MailAddress
message.To.Add(txtEmail.Text);
message.Subject = "Feedback";

//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = false;

// Message body content
message.Body = txtMessage.Text;

// Send SMTP mail
smtpClient.Send(message);

lblStatus.Text = "Email successfully sent.";
}
catch (Exception ex)
{
lblStatus.Text = "Send Email Failed.<br>" + ex.Message;
}


Please helps me out


Thanks
durga.




Responses

#443993    Author: venkatesan.M      Member Level: Gold      Member Rank: 30     Date: 18/Nov/2009   Rating: 2 out of 52 out of 5     Points: 2

Your MailServer was not allowed to send email to other id or any

you can send only your companymail , due to restriction on your main server.

Regards,
M.Venkatesan.

For Interview Question and Answers:
http://dotnet-interview-qa.blogspot.com

http://venkatdotnetexperiments.wordpress.com
Dot Net Code Snippets


 
#443994    Author: Mohan      Member Level: Gold      Member Rank: 102     Date: 18/Nov/2009   Rating: 2 out of 52 out of 5     Points: 2

It may be your given smtp server restrict these options.

Regards

Mohan Kumar.D


 
#443998    Author: HimaBindu Vejella      Member Level: Gold      Member Rank: 42     Date: 18/Nov/2009   Rating: 2 out of 52 out of 5     Points: 2

may be your SMTP/ Firewall is restricting that

http://himabinduvejella.blogspot.com
http://sysntaxhelp.com/asp.net
http://groups.google.com/group/mugh
Hima's Tech Blog





 
#444149    Author: Gaurav Arora        Member Level: Gold      Member Rank: 32     Date: 18/Nov/2009   Rating: 2 out of 52 out of 5     Points: 2

Check your company's network guys and go through firewall restrictions.



Thanks & regards,
Gaurav Arora - Lead Editor
My Portal - http://msdotnetheaven.com
Nangal Dam - http://mynangal.com
Me in My Own Style


 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : What is Abstract factory Method in Design Pattern (.NET)
Previous : Exam 70-536
Return to Discussion Forum
Post New Message
Category:

Related Messages

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2013 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.