473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Failure to Send email

I am trying to send email using this fucntion can you guys help me finding
the mistake

I am using my Gmail Credentials and the only exception error I get is

Failure sending email

Any help is greatly appreciated

=====================

MailMessage mailMessage = new MailMessage();

try

{

SmtpClient client = new SmtpClient();

client.Host = SMPTPServerTextBox.Text.Trim();

string emailUserName = FromAddressEmailTextBox.Text.Trim();

string emailPassword = EmailPasswordTextBox.Text.Trim();

client.Credentials = new NetworkCredential(emailUserName, emailPassword);

client.EnableSsl = true;

string toAddress = ToAddressEmailTextBox.Text.Trim();

mailMessage.To.Add(new MailAddress(toAddress));

mailMessage.From = new MailAddress(emailUserName);

mailMessage.Subject = SubjectTextBox.Text.Trim();

mailMessage.Body = EmailBodyTextBox.Text.Trim();

client.Send(mailMessage);

EmailResultTextBox.Text = "Successfully Send Email";

// Logger.LogInfo("Successfully Sent Email");

}

catch (Exception ex)

{

EmailResultTextBox.Text = ex.Message;
}

Oct 31 '06 #1
1 2691
See
2/8/2006
Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and 2.0)

http://sholliday.spaces.live.com/blog/
I have the correct gmail settings for 1.1 and 2.0 there.


"NW Technicals" <an*******@someone.comwrote in message
news:e6**************@TK2MSFTNGP05.phx.gbl...
I am trying to send email using this fucntion can you guys help me finding
the mistake

I am using my Gmail Credentials and the only exception error I get is

Failure sending email

Any help is greatly appreciated

=====================

MailMessage mailMessage = new MailMessage();

try

{

SmtpClient client = new SmtpClient();

client.Host = SMPTPServerTextBox.Text.Trim();

string emailUserName = FromAddressEmailTextBox.Text.Trim();

string emailPassword = EmailPasswordTextBox.Text.Trim();

client.Credentials = new NetworkCredential(emailUserName, emailPassword);

client.EnableSsl = true;

string toAddress = ToAddressEmailTextBox.Text.Trim();

mailMessage.To.Add(new MailAddress(toAddress));

mailMessage.From = new MailAddress(emailUserName);

mailMessage.Subject = SubjectTextBox.Text.Trim();

mailMessage.Body = EmailBodyTextBox.Text.Trim();

client.Send(mailMessage);

EmailResultTextBox.Text = "Successfully Send Email";

// Logger.LogInfo("Successfully Sent Email");

}

catch (Exception ex)

{

EmailResultTextBox.Text = ex.Message;
}

Oct 31 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: HoustonComputerGuy | last post by:
I am working on getting my web applications moved to .Net 2.0 and am having some problems with System.Net.Mail. I get the following error when sending the mail: System.Net.Mail.SmtpException was...
1
by: NW Technicals | last post by:
I am trying to send email using this fucntion can you guys help me please find the mistake I am using my Gmail Credentials and the only exception error I get is Failure sending email Any...
1
by: NW Technicals | last post by:
I am trying to send email using this fucntion can you guys help me please finding the mistake I am using my Gmail Credentials and the only exception error I get is Failure sending email Any...
13
by: Rob | last post by:
Hi all, I am fairly new to python, but not programming and embedded. I am having an issue which I believe is related to the hardware, triggered by the software read I am doing in pySerial. I...
1
by: Chubbly Geezer | last post by:
Hi I am using the following code to send an email from within my program:- MailMessage theMailMessage = new MailMessage("from@email.com", "to@email.com"); theMailMessage.Body = "body email...
2
by: satnamsarai | last post by:
Using System.Net.Mail: Sometimes I get error 'failure sending mail. Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.' Not sure how...
9
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient...
8
by: =?Utf-8?B?TWFyaw==?= | last post by:
We've got a wierd failure happening on just one machine. One part of our product uses a 3rd party search implementation (dtSearch). DtSearch has a native core (dten600.dll), late-bound, and a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.