I am trying to send email in C#. I wrote 2 pieces of code:
1.
MailMessage mail = new MailMessage();
mail.From = "from_address";
mail.To = "to_address";
mail.Subject = "subject";
mail.BodyFormat = MailFormat.Text;
mail.Body = "body";
SmtpMail.SmtpServer = "smtp.server";
mail.Fields.Clear();
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "userl");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "25");
SmtpMail.Send(mail);
/////////////////////////////////////////////////////////////////////////////////////////////
2.
MailMessage mail = new MailMessage("from_address", "to_addressl");
mail.Subject = "subject";
mail.Body = "body";
SmtpClient smtp = new SmtpClient("smtp.server", 25);
smtp.EnableSsl = false;
smtp.Credentials = new System.Net.NetworkCredential("user", "password");
smtp.Send(mail);
I am thrown error:
System.Net.Mail.SmtpException: Failure sending mail. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: A connection attempt failed because the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond
what is wrong.?
PS
I wrote another application (in borland c++) where I specified the same data
(from/to addresse, server address, user/password) and it works ok 5 23720
Try adding the '@' character before your quoted strings:
i.e.
mail.Fileds.Add(@"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");
The compiler may be interpreting everything after // as a comment.
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.com...
>I am trying to send email in C#. I wrote 2 pieces of code:
1.
MailMessage mail = new MailMessage();
mail.From = "from_address";
mail.To = "to_address";
mail.Subject = "subject";
mail.BodyFormat = MailFormat.Text;
mail.Body = "body";
SmtpMail.SmtpServer = "smtp.server";
mail.Fields.Clear();
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
"userl");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
"password");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",
"25");
SmtpMail.Send(mail);
/////////////////////////////////////////////////////////////////////////////////////////////
2.
MailMessage mail = new MailMessage("from_address", "to_addressl");
mail.Subject = "subject";
mail.Body = "body";
SmtpClient smtp = new SmtpClient("smtp.server", 25);
smtp.EnableSsl = false;
smtp.Credentials = new System.Net.NetworkCredential("user", "password");
smtp.Send(mail);
I am thrown error:
System.Net.Mail.SmtpException: Failure sending mail. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: A connection attempt failed because
the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond
what is wrong.?
PS
I wrote another application (in borland c++) where I specified the same
data
(from/to addresse, server address, user/password) and it works ok
You need to make sure your smtp server is reachable, that is try to connect
to it using something simple like "ping" or "telnet smtp.server 25".
Firewall may block this port as well, so watch out for them.
Willy.
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.com...
|I am trying to send email in C#. I wrote 2 pieces of code:
| 1.
| MailMessage mail = new MailMessage();
| mail.From = "from_address";
| mail.To = "to_address";
| mail.Subject = "subject";
| mail.BodyFormat = MailFormat.Text;
| mail.Body = "body";
| SmtpMail.SmtpServer = "smtp.server";
| mail.Fields.Clear();
|
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1");
|
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
"userl");
|
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
"password");
|
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",
"25");
| SmtpMail.Send(mail);
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
| 2.
|
| MailMessage mail = new MailMessage("from_address", "to_addressl");
| mail.Subject = "subject";
| mail.Body = "body";
| SmtpClient smtp = new SmtpClient("smtp.server", 25);
| smtp.EnableSsl = false;
| smtp.Credentials = new System.Net.NetworkCredential("user", "password");
| smtp.Send(mail);
|
|
| I am thrown error:
|
| System.Net.Mail.SmtpException: Failure sending mail. --->
| System.Net.WebException: Unable to connect to the remote server --->
| System.Net.Sockets.SocketException: A connection attempt failed because
the
| connected party did not properly respond after a period of time, or
| established connection failed because connected host has failed to respond
|
|
| what is wrong.?
|
| PS
| I wrote another application (in borland c++) where I specified the same
data
| (from/to addresse, server address, user/password) and it works ok
Jim Boddie wrote:
Try adding the '@' character before your quoted strings:
i.e.
mail.Fileds.Add(@"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");
The compiler may be interpreting everything after // as a comment.
No - otherwise the line wouldn't compile in the first place.
Forward slashes are fine in string literals. Verbatim string literals
(i.e. those with the @ in front) deal with escaping which is normally
done with backslashes.
Jon
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.com...
>I am trying to send email in C#. I wrote 2 pieces of code:
1.
MailMessage mail = new MailMessage();
mail.From = "from_address";
mail.To = "to_address";
mail.Subject = "subject";
mail.BodyFormat = MailFormat.Text;
mail.Body = "body";
SmtpMail.SmtpServer = "smtp.server";
mail.Fields.Clear();
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
"userl");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
"password");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",
"25");
SmtpMail.Send(mail);
/////////////////////////////////////////////////////////////////////////////////////////////
2.
MailMessage mail = new MailMessage("from_address", "to_addressl");
mail.Subject = "subject";
mail.Body = "body";
SmtpClient smtp = new SmtpClient("smtp.server", 25);
smtp.EnableSsl = false;
smtp.Credentials = new System.Net.NetworkCredential("user", "password");
smtp.Send(mail);
I am thrown error:
System.Net.Mail.SmtpException: Failure sending mail. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: A connection attempt failed because
the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond
what is wrong.?
PS
I wrote another application (in borland c++) where I specified the same
data
(from/to addresse, server address, user/password) and it works ok
I'd double check you can telnet into it on port 25 as someone else said -
I've used code similar to your version 2 and it works ok...
Chris,
Those schema.microsoft.com things are tricky.
You also need to be aware of the different authentication schemes.
None
Basic
SSL
I have complete downloadable examples (1.1 and 2.0) at: http://sholliday.spaces.live.com/?_c...26ayear%3d2006
2/8/2006 datestamp
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.com...
I am trying to send email in C#. I wrote 2 pieces of code:
1.
MailMessage mail = new MailMessage();
mail.From = "from_address";
mail.To = "to_address";
mail.Subject = "subject";
mail.BodyFormat = MailFormat.Text;
mail.Body = "body";
SmtpMail.SmtpServer = "smtp.server";
mail.Fields.Clear();
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenti
cate", "1");
>
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername
", "userl");
>
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword
", "password");
>
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverpo
rt", "25");
SmtpMail.Send(mail);
////////////////////////////////////////////////////////////////////////////
/////////////////
2.
MailMessage mail = new MailMessage("from_address", "to_addressl");
mail.Subject = "subject";
mail.Body = "body";
SmtpClient smtp = new SmtpClient("smtp.server", 25);
smtp.EnableSsl = false;
smtp.Credentials = new System.Net.NetworkCredential("user", "password");
smtp.Send(mail);
I am thrown error:
System.Net.Mail.SmtpException: Failure sending mail. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: A connection attempt failed because
the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond
what is wrong.?
PS
I wrote another application (in borland c++) where I specified the same
data
(from/to addresse, server address, user/password) and it works ok
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: aa |
last post by:
Since recently opening a php file on my w2k Pro takes ages and often ends up
with an error massege "cannot conect to fastcgi server".
However if I refresh the page it starts working normally.
How...
|
by: Amol Shambharkar |
last post by:
Hello Everyone,
I am hoping someone could help me out with this.I am using Visual
Studio .NET 2003 to create a web application on a remote IIS 5.0
server using the File Share web access method.The...
|
by: tony010409020622 |
last post by:
My WebForm1.aspx works fine when I connect via localhost, AND when I
connect using the IP address. HOWEVER, NO ONE ELSE can connect using
my IP address. Capitalization is correct, Firewall is off,...
|
by: Emilio |
last post by:
Question about
Shared Sub Connect(server As , message As )
Why is in square brackets?
Is it like
Shared Sub Connect(server() As String, message() As String)
|
by: Chris L |
last post by:
Hi there,
I'm running VS.NET 2003 on XP Home, so I have Web Matrix installed as a web
server.
I wanted to create my first web application with VS.NET, but when I select
New Project -> asp.net...
|
by: yodboy |
last post by:
hi there
Im going nuts - any help appreciated
trying to connect to access db over a network
so far -
I can connect to the db using the same odbc with excel
I can connect to a copy of the...
|
by: suhailkhalil |
last post by:
I'm using javascirpt calendar control and using the below statement to populate date in textbox txtDate. I'm using master page in VS2005.
...
|
by: jeffhan |
last post by:
we have os/400 db2 database at the backend.
i installed db2 v9 connect server on one windows server which is
locating the same network with database server.
now how to i configure the connect...
|
by: Jean-Marc Blaise |
last post by:
Hi,
I have installed DB2 9.5 directly from FP1 on Windows in custom mode with
COMP=CONNECT_SUPPORT. I then added my DB2 Server license.
I am surprise that db2licm refers to a DB2 Connect...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
| |