0

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

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by LizR
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.

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.