954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem With Sending Email Through Asp.net

I'm trying to sending Email through my web application from Gmail
by using Sustem.Net.Mail.SmtpClient
My code is

string To = "doctor_ofvet@yahoo.com";
        string From = "doctorofvet@gmail.com";
        string Subject = "The Famous";
        string Body = "Hello World";
        SmtpClient Client = new SmtpClient();
        Client.Send(From, To, Subject, Body);


I put this code in the web.config file

<system.net>
		<mailSettings>
			<smtp>
				<network host="smtp.gmail.com" port="465" userName="Gmail Username" password="Password"/>
			</smtp>
		</mailSettings>
	</system.net>


but it did not success

compovet
Newbie Poster
20 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

can any one help me please

compovet
Newbie Poster
20 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

Hi there,

Last time I mailed with C#-code, it happened like this:

MailMessage mailMessage;
SmtpClient client;

mailMessage = new MailMessage();
client = new SmtpClient("relay.skynet.be"); //your mail-out server
mailMessage.To.Add("...@hotmail.com");
mailMessage.Subject = "...";
client.Send(mailMessage);

This was not in a web application but just a C#.NET windows application. I hope this helps you.

EastStreetEagle
Newbie Poster
5 posts since Nov 2008
Reputation Points: 10
Solved Threads: 1
 

debugging would show wether your mail settings are being picked up for your new smtpclient. If not, it maybe better to set them.

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You