473,513 Members | 2,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Please-- Failure sending Email

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 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 1672
Hi,

you have client.EnableSsl = true;

try client.EnableSsl = false; and see

Nirosh.

"NW Technicals" <an*******@someone.comwrote in message
news:eJ**************@TK2MSFTNGP05.phx.gbl...
>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 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

1
1190
by: VB Programmer | last post by:
I am making a simple VB.NET app to send emails. I put a test button on the form with code like this: Imports System.Web.Mail : Dim msgEmail As New System.Web.Mail.MailMessage With msgEmail...
3
57588
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...
2
10129
by: HK | last post by:
In VB.NET, I'm getting the exception "failure sending mail". I'm running VS 2005 on XP Home. This is a new install on a new PC. I've never had email problems with VS 2003, and there I could...
1
1244
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...
11
6627
jamesd0142
by: jamesd0142 | last post by:
'server address Dim client As New SmtpClient("imap.uk.aol.com", 143) 'username and password client.Credentials = New Net.NetworkCredential("my username", "mypassword") ...
9
3434
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...
1
1339
by: shripal | last post by:
hello i am new to php. i want to email to client from my website. but i am not able to send email . it all time executes statement "Mail send failure - message not sent"
2
1618
by: Wayne | last post by:
I'm using the following code to send email addresses from a query to Outlook: Dim db As Database, rs As Recordset, sql As String, emailTo As String Set db = CurrentDb() emailTo = "" sql =...
1
6128
maliksleo
by: maliksleo | last post by:
hi i am using the following class for email sending but getting this error "Failure sending mail" Imports System.Net.Mail Public Class MailHelper ''' <summary> ''' Sends an mail...
0
7260
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,...
1
7101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5089
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.