How do I send mail using C#?Does anyone have a code snippet that shows how to send mail from c#?© 2009 Microsoft Corporation. All rights reserved.Mon, 02 Nov 2009 09:25:33 Za75533eb-131b-4ff3-a3b2-b6df87c25cc8http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#a75533eb-131b-4ff3-a3b2-b6df87c25cc8http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#a75533eb-131b-4ff3-a3b2-b6df87c25cc8Josh Ledgardhttp://social.msdn.microsoft.com/Profile/en-US/?user=Josh%20LedgardHow do I send mail using C#?Does anyone have a code snippet that shows how to send mail from c#?Wed, 06 Apr 2005 23:21:19 Z2006-12-23T06:48:55Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#8d2e7d43-1ed5-4f7d-a4f2-8f33ed0610c0http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#8d2e7d43-1ed5-4f7d-a4f2-8f33ed0610c0Josh Ledgardhttp://social.msdn.microsoft.com/Profile/en-US/?user=Josh%20LedgardHow do I send mail using C#?<p>Here is the code snippet I found...</p> <p>System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();<br />message.To.Add("<a target="_blank" title="mailto:luckyperson@online.microsoft.com" href="mailto:luckyperson@online.microsoft.com">luckyperson@online.microsoft.com</a>");<br />message.Subject = "This is the Subject line";<br />message.From = new System.Net.Mail.MailAddress("<a target="_blank" title="mailto:From@online.microsoft.com" href="mailto:From@online.microsoft.com">From@online.microsoft.com</a>");<br />message.Body = "This is the message body";<br />System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");<br />smtp.Send(message);<br /></p>Wed, 06 Apr 2005 23:22:03 Z2006-04-21T16:15:14Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#be64bc86-13b7-455f-b362-1766970ee2f9http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#be64bc86-13b7-455f-b362-1766970ee2f9Mohamed Meligyhttp://social.msdn.microsoft.com/Profile/en-US/?user=Mohamed%20MeligyHow do I send mail using C#?<p align="justify">Dear Josh,<br />Thank you very much for the great post. It really demonstrates everything easily. Hope that you wouldn't mind some minor notes&nbsp;about it anyway:<br />1-The namespace System.Net.Mail&nbsp;is a part of the class library of .NET framwork 2.0 (currently in BETA version), to send mail using .NET framework 1.1, you'd use System.Web.Mail instead..<br />2-There's no class called SmtpClient in the System.Web.Mail namspace, but it's a member of the System.Net.Mail namspace in .NET Framework 2.0.<br /><br />To send mail via Microsoft .NET Framework 1.1 (the current version) you can use:</p> <table style="WIDTH: 100%" cellspacing="1" cellpadding="1" border="1"> <tbody> <tr> <td><font size="2"> <p>System.Web.Mail.MailMessage message=</font><font color="#0000ff" size="2">new</font><font size="2"> System.Web.Mail.MailMessage();<br />message.From="from e-mail";<br />message.To="to e-mail";<br />message.Subject="Message Subject";<br />message.Body="Message Body";<br />System.Web.Mail.SmtpMail.SmtpServer="SMTP Server Address";<br />System.Web.Mail.SmtpMail.Send(message);</p></font></td></tr></tbody></table>If you want the shortest way:<br /> <table style="WIDTH: 100%" cellspacing="1" cellpadding="1" border="1"> <tbody> <tr> <td><font size="2"><font size="2"> <p>System.Web.Mail.SmtpMail.SmtpServer="SMTP Host Address";<br />System.Web.Mail.SmtpMail.Send("from","To","Subject","MessageText");</font></font></p></td></tr></tbody></table> <p align="justify"><br />Now, in fact, both segments of code will not work for most SMTP hosts. This is because most SMTP hosts today require authentication (user/pass) to allow you to use the server. To send mail using Authenticated SMTP, many people use third party tools. There are many out there and some of them are good and free, but, System.Web.Mail doesn't need that really. You can send mail via Authenticated SMTP mail servers using the 1st code I wrote, just add the <strong>bold</strong> lines to it to be:<br /></p> <table style="WIDTH: 100%" cellspacing="1" cellpadding="1" border="1"> <tbody> <tr> <td><font size="2"> <p>System.Web.Mail.MailMessage message=</font><font color="#0000ff" size="2">new</font><font size="2"> System.Web.Mail.MailMessage();</p> <p><strong>message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1 );<br />message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername","SmtpHostUserName" );<br />message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword","SmtpHostPassword" );</strong><br /><br />message.From="from e-mail";<br />message.To="to e-mail";<br />message.Subject="Message Subject";<br />message.Body="Message Body";</p> <p>System.Web.Mail.SmtpMail.SmtpServer="SMTP Server Address";<br />System.Web.Mail.SmtpMail.Send(message);</p></font></td></tr></tbody></table><br />For more detailed information on sending mail using .NET framework 1.1, check <a target="_blank" title="http://www.systemwebmail.com/default.aspx" href="http://www.systemwebmail.com/default.aspx">this detailed FAQ</a> (take care, it's often detailed more than you may need!).<br />For information on the System.Net.Mail namespace in Microsoft.NET Framework 2.0, you may check <a title="Visual Studio 2005 Library" href="http://msdn2.microsoft.com/library/default.aspx" xmlns="">Visual Studio 2005 Library </a>&nbsp;&gt;&nbsp;<a title=".NET Framework Reference" href="http://msdn2.microsoft.com/library/x9t6k3aa.aspx" xmlns="">.NET Framework Reference</a>&nbsp;&gt;&nbsp;<a title="Class Library" href="http://msdn2.microsoft.com/library/d11h6832.aspx" xmlns="">Class Library</a>&nbsp;&gt;&nbsp;<a title="System" href="http://msdn2.microsoft.com/library/dk1fb84h.aspx" xmlns="">System.Net.Mail</a>.<br /><br />Wish to hear if this could help<br />Regards,Fri, 08 Apr 2005 02:15:03 Z2005-11-16T17:52:21Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#340e26ce-368a-4b4a-9c62-646429a75d56http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#340e26ce-368a-4b4a-9c62-646429a75d56Stevan Veselinovichttp://social.msdn.microsoft.com/Profile/en-US/?user=Stevan%20VeselinovicHow do I send mail using C#?You can always send e-mail using the end-users Microsoft Office Outlook interface. To do so, the needed library is provided below:<br /><a target="_blank" title="http://www.xblogs.org/Downloads/AppLibraries/OutlookMail.zip" href="http://www.xblogs.org/Downloads/AppLibraries/OutlookMail.zip">http://www.xblogs.org/Downloads/AppLibraries/OutlookMail.zip</a>Fri, 08 Apr 2005 03:25:28 Z2005-04-08T03:25:28Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#e42c1937-b508-4918-9057-8f5f1204a188http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#e42c1937-b508-4918-9057-8f5f1204a188Uwe Keimhttp://social.msdn.microsoft.com/Profile/en-US/?user=Uwe%20KeimHow do I send mail using C#?Recently I used <a target="_blank" title="http://www.quiksoft.com/freesmtp/" href="http://www.quiksoft.com/freesmtp/">FreeSmtp.NET</a> successfully. It allows to send text- and HTML-messages with inline images and of course with attachments.<br /><br />It even allows to send text and HTML inside <em>one </em>message (multiple mime-parts).<br /><br />Fri, 08 Apr 2005 04:41:27 Z2008-03-13T12:53:00Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#f1e46111-09f5-495f-8c34-8bd5c6d94132http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#f1e46111-09f5-495f-8c34-8bd5c6d94132V3M4http://social.msdn.microsoft.com/Profile/en-US/?user=V3M4How do I send mail using C#?<p>Not that everyone cares, just that maybe one or two do. Here's how to post an email to an Exchange Server mailbox over http using WebDAV.<br /><br /><font face="Courier New" color="#000000" size="2">public static void SendEmail(string server, string mailbox, string password, string to, string subject, string body, bool secureHttp)<br />{<br />&nbsp;string httpProtocol = secureHttp ? "https://" : "http://";<br />&nbsp;string mailboxUri = httpProtocol + server + "/" + mailbox;<br />&nbsp;string submissionUri = httpProtocol + server + "/" + mailbox + "/##DavMailSubmissionURI##/";<br />&nbsp;string draftsUri = "http://" + server + "/" + mailbox + "/drafts/" + subject + ".eml";</font></p> <p><font face="Courier New" color="#000000" size="2">&nbsp;string message = "To: " + to + "\n" +<br />&nbsp;"Subject: " + subject + "\n" +<br />&nbsp;"Date: " + System.DateTime.Now +<br />&nbsp;"X-Mailer: mailer" + "\n" +<br />&nbsp;"MIME-Version: 1.0" + "\n" +<br />&nbsp;"Content-Type: text/plain;" + "\n" +<br />&nbsp;"Charset = \"iso-8859-1\"" + "\n" +<br />&nbsp;"Content-Transfer-Encoding: 7bit" + "\n" +<br />&nbsp;"\n" + body;</font></p> <p><font face="Courier New" color="#000000" size="2">&nbsp;// Credentials for exchange requests.<br />&nbsp;CredentialCache credentials = new CredentialCache();<br />&nbsp;credentials.Add(new Uri(mailboxUri), "NTLM", new NetworkCredential(mailbox, password));</font></p> <p><font face="Courier New" color="#000000" size="2">&nbsp;// Request to put an email the drafts folder.<br />&nbsp;HttpWebRequest putRequest = (HttpWebRequest)HttpWebRequest.Create(draftsUri);<br />&nbsp;putRequest.Credentials = credentials;<br />&nbsp;putRequest.Method = "PUT";<br />&nbsp;putRequest.ContentType = "message/rfc822";</font></p> <p><font face="Courier New" color="#000000" size="2">&nbsp;byte[] bytes = Encoding.UTF8.GetBytes((string)message);<br />&nbsp;putRequest.ContentLength = bytes.Length;</font></p> <p><font face="Courier New" color="#000000" size="2">&nbsp;Stream putRequestStream = putRequest.GetRequestStream();<br />&nbsp;putRequestStream.Write(bytes, 0, bytes.Length);<br />&nbsp;putRequestStream.Close();</font></p> <p><font face="Courier New" color="#000000" size="2">&nbsp;// Put the message in the Drafts folder of the sender's mailbox.<br />&nbsp;WebResponse putResponse = (HttpWebResponse)putRequest.GetResponse();<br />&nbsp;putResponse.Close();</font></p> <p><font face="Courier New" color="#000000" size="2">&nbsp;// Request to move the email from the drafts to the mail submission Uri.<br />&nbsp;HttpWebRequest moveRequest = (HttpWebRequest)HttpWebRequest.Create(draftsUri);<br />&nbsp;moveRequest.Credentials = credentials;<br />&nbsp;moveRequest.Method = "MOVE";<br />&nbsp;moveRequest.Headers.Add("Destination", submissionUri);</font></p> <p><font face="Courier New" color="#000000" size="2">&nbsp;// Put the message in the mail submission folder.<br />&nbsp;WebResponse moveResponse = (HttpWebResponse)moveRequest.GetResponse();<br />&nbsp;moveResponse.Close();<br />}</font></p>Fri, 08 Apr 2005 05:59:55 Z2008-03-13T12:53:30Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#d44fa3f5-1eb5-438a-b25f-a8ed4b98625dhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#d44fa3f5-1eb5-438a-b25f-a8ed4b98625dnicpnhttp://social.msdn.microsoft.com/Profile/en-US/?user=nicpnHow do I send mail using C#?Similar to Josh: I need to know how to send mail using C#. I have a class that will be throwing parameters (see below):<br /><font color="#0000ff" size="2"> <p>private</font><font size="2"> </font><font color="#0000ff" size="2">void</font><font size="2"> SendToAnalyst()</p> <p>{</p> <p></font><font color="#0000ff" size="2">string</font><font size="2"> emailSubject = </font><font color="#0000ff" size="2">string</font><font size="2">.Empty;</p> <p></font><font color="#0000ff" size="2">string</font><font size="2"> emailAddress = </font><font color="#0000ff" size="2">string</font><font size="2">.Empty;</p> <p>StringBuilder sb = </font><font color="#0000ff" size="2">new</font><font size="2"> StringBuilder();</p> <p></font><font color="#008000" size="2">//To Do: Instantiate Monitoring Component</p></font><font size="2"> <p></font><font color="#0000ff" size="2">if</font><font size="2">(mSourceSystem.ToUpper().Equals("FLEXCAB"))</p> <p>{</p> <p>emailSubject = "Sample RequestId (FLEXCAB To RADTI RESPONSE): "+mSampleRequestID;</p> <p></p> <p>sb.Append("**************************************************************************************\n");</p> <p>sb.Append("\n");</p> <p>sb.Append("Please do not reply to this email. This is a System generated email.\n");</p> <p>sb.Append("\n");</p> <p>sb.Append("**************************************************************************************\n");</p> <p>sb.Append("\n");</p> <p>sb.Append("Sample Request ID: "+mSampleRequestID+"\n");</p> <p>sb.Append("Request Status: "+ mReqStatus+"\n");</p> <p>sb.Append("\n");</p> <p>sb.Append("Please Correct the error and re-submit.\n");</p> <p>sb.Append("Or Call the EDS DBA on 03-8866-7424\n");</p> <p></font><font color="#008000" size="2">//Console.WriteLine(sb.ToString());</p></font><font size="2"> <p></font><font color="#008000" size="2">// Send the email body to Monitoring component</p></font><font size="2"> <p>}</p> <p>}</p> <p>The send mail class I am trying to create should catch the parameters from this SendToAnalyst class.</p></font>Mon, 02 May 2005 04:46:36 Z2005-05-02T04:46:36Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#6f956ace-e2b3-47a0-83a2-9114101f4bb8http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#6f956ace-e2b3-47a0-83a2-9114101f4bb8J.S_http://social.msdn.microsoft.com/Profile/en-US/?user=J.S_How do I send mail using C#?Is this for sending mail from a web page or from a Windows Forms application?&nbsp; Thanks!<br /> <br /> <div class=quote><table width="85%"><tr><td class="txt4">&nbsp;<strong>Josh Ledgard wrote:</strong></td></tr><tr><td class="quoteTable"><table width="100%"><tr><td width="100%" valign="top" class="txt4"><p>Here is the code snippet I found...</p> <p>System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();<br />message.To.Add("<a target="_blank" title="mailto:luckyperson@online.microsoft.com" href="mailto:luckyperson@online.microsoft.com">luckyperson@online.microsoft.com</a>");<br />message.Subject = "This is the Subject line";<br />message.From = new System.Net.Mail.MailAddress("<a target="_blank" title="mailto:From@online.microsoft.com" href="mailto:From@online.microsoft.com">From@online.microsoft.com</a>");<br />message.Body = "This is the message body";<br />System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");<br />smtp.Send(message);<br /></p></td></tr></table></td></tr></table></div>Thu, 01 Sep 2005 17:55:46 Z2005-09-01T17:55:46Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#82b76ecd-606b-48ce-8090-1bb036d803cahttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#82b76ecd-606b-48ce-8090-1bb036d803caJosh Ledgardhttp://social.msdn.microsoft.com/Profile/en-US/?user=Josh%20LedgardHow do I send mail using C#?<p>The system.net.mail class is the recomended way to handle mail sends no matter what sort of application you are building.&nbsp; </p>Thu, 01 Sep 2005 19:04:23 Z2005-09-01T19:04:23Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#360a6311-3397-4522-9747-d5bd1a17bc23http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#360a6311-3397-4522-9747-d5bd1a17bc23J.S_http://social.msdn.microsoft.com/Profile/en-US/?user=J.S_How do I send mail using C#?Thanks, Josh!<br /> Fri, 02 Sep 2005 01:11:52 Z2005-09-02T01:11:52Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#b75f34d5-14d8-43d9-adf4-d307b1b1e6e3http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#b75f34d5-14d8-43d9-adf4-d307b1b1e6e3redspiderhttp://social.msdn.microsoft.com/Profile/en-US/?user=redspiderHow do I send mail using C#?Hi josh<br /><br />I use your code at the office it is working fine, but at home i get with te same code an error:<br /><br />SmtpException was unhandled&nbsp;&nbsp; Failure sending mail.<br /><br />I use a winXP Pro SP2 only the smtp server is different ?<br /><br />can&nbsp;you help me&nbsp;<br /><br />thanks<br />redspiderMon, 26 Sep 2005 19:54:23 Z2005-09-26T19:54:23Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#862eb321-d218-4d0d-a12f-56a6c81eeabbhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#862eb321-d218-4d0d-a12f-56a6c81eeabbAhmed Mostafahttp://social.msdn.microsoft.com/Profile/en-US/?user=Ahmed%20MostafaHow do I send mail using C#?<p>This was helful,<br /><br />but the only problem that I face is <strong>authentication</strong>, so please provide an explicit example.<br /><br />Let us say for instance that my e-mail (from field) is: "from@yahoo.com" with user&nbsp;name: "from" and password: "password", and I am sending to: "to@hotmail.com".<br /><br />That is what I am trying to do for months <img src="/msdn//emoticons/emotion-6.gif" alt="Sad" /> ...<br /><br />Thanks a lot</p>Fri, 14 Oct 2005 07:04:10 Z2005-10-14T07:04:10Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#b36f1b84-1cff-4e9e-84d7-4767b25aaca3http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#b36f1b84-1cff-4e9e-84d7-4767b25aaca3Ahmed Mostafahttp://social.msdn.microsoft.com/Profile/en-US/?user=Ahmed%20MostafaHow do I send mail using C#?<p>I forget to ask how to get the SMTP name of my mail server?<br />Is it like: mail.yahoo.com, hotmail.com, gmail.com ? or what?<br /><br />Thanks again</p>Fri, 14 Oct 2005 07:11:19 Z2005-10-14T07:11:19Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#88b835f6-cc41-4928-86da-e3811b096831http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#88b835f6-cc41-4928-86da-e3811b096831redspiderhttp://social.msdn.microsoft.com/Profile/en-US/?user=redspiderHow do I send mail using C#?Hi, <br /><br />I have McAffee Scan On-Access disabled and&nbsp;problem is gone&nbsp;<br /><br />greetz<br />Sat, 12 Nov 2005 22:50:17 Z2005-11-12T22:50:17Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#6cc3b4fe-81d0-4e7f-a324-3b7b315e2a74http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#6cc3b4fe-81d0-4e7f-a324-3b7b315e2a74pelicanoushttp://social.msdn.microsoft.com/Profile/en-US/?user=pelicanousHow do I send mail using C#?<P>Dear Mohamed,</P> <P>&nbsp;</P> <P>I was very interested to try the code snippet using authentificated SMTP you gave us, but I cannot find and member Fields in the&nbsp;System.Web.Mail.MailMessage object.</P> <P>How come I am the only one ? Did I do something wrong ? </P> <P>Thanks, </P> <P>&nbsp;</P> <P>&nbsp;</P>Wed, 11 Jan 2006 17:03:53 Z2006-01-11T17:03:53Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#7b884e2a-c974-44fb-a925-27b28afeb8c4http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#7b884e2a-c974-44fb-a925-27b28afeb8c4sandude7http://social.msdn.microsoft.com/Profile/en-US/?user=sandude7How do I send mail using C#?<span> <span> <p>hi i need to send e-mail through my C# application (VS .NET 2003)..i am using mohamed's code but getting the following exception</p> <p> </p> <p>System.Web.HttpException: Could not access 'CDO.Message' object. ---&gt; System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.Runtime.InteropServices.COMException (0x8004020E): The server rejected the sender address. The server response was: 530 5.7.0 Must issue a STARTTLS command first f17sm780958qba</p> <p> </p> <p>could you guys help me in sorting this out...Thanks in advance</p></span></span>Tue, 21 Feb 2006 12:32:07 Z2006-02-21T12:32:07Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#bf6f5c80-4358-43d0-8b76-9d9670be1c40http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#bf6f5c80-4358-43d0-8b76-9d9670be1c40sandude7http://social.msdn.microsoft.com/Profile/en-US/?user=sandude7How do I send mail using C#?<P>Hi all...I could rectify the above problem by adding this line</P><FONT size=2> <P>message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");</P> <P>I was using GMAIL smtp server which requires SSL.</P> <P>Thanks</P> <P>&nbsp;</P></FONT>Fri, 24 Feb 2006 14:59:18 Z2006-02-24T14:59:18Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#8dd5a615-723d-4543-9678-1cfd4cb6c13dhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#8dd5a615-723d-4543-9678-1cfd4cb6c13dGreg Younghttp://social.msdn.microsoft.com/Profile/en-US/?user=Greg%20YoungHow do I send mail using C#?<p>I had written another open source client one afternoon some time ago though it is rather useless with 2.0 (except for the email validation code) <a title="http://sourceforge.net/projects/no-cdo" href="http://sourceforge.net/projects/no-cdo">http://sourceforge.net/projects/no-cdo</a></p> <p>Cheers,</p> <p>Greg</p>Tue, 28 Feb 2006 21:13:16 Z2006-02-28T21:13:16Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#2991911d-9701-4aab-a831-d3d383e9bbddhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#2991911d-9701-4aab-a831-d3d383e9bbddÖmer KUŞCUhttp://social.msdn.microsoft.com/Profile/en-US/?user=%u00d6mer%20KU%u015eCUHow do I send mail using C#?<font color="#0000ff" size=2> <p>public</font><b><font size=2> </b></font><font color="#0000ff" size=2>void</font><b><font size=2> Send() {</p></b><b> <p></b></font><font color="#008080" size=2>MailMessage</font><b><font size=2> MailMesaji = </b></font><font color="#0000ff" size=2>new</font><b><font size=2> </b></font><font color="#008080" size=2>MailMessage</font><b><font size=2>();</p></b><b> <p>MailMesaji.Subject = </b></font><font color="#800000" size=2>&quot;subject&quot;</font><b><font size=2>;</p> <p>MailMesaji.Body = </b></font><font color="#800000" size=2>&quot;mail body&quot;</font><b><font size=2>;</p> <p>MailMesaji.BodyEncoding = </b></font><font color="#008080" size=2>Encoding</font><font size=2>.GetEncoding(</font><font color="#800000" size=2>&quot;Windows-1254&quot;</font><b><font size=2>); </b></font><font color="#008000" size=2>// Turkish Character Encoding</p></font><b><font size=2> <p>MailMesaji.From = </b></font><font color="#800000" size=2>&quot;sender mail adress&quot;</font><b><font size=2>;</p> <p></b></font><font color="#0000ff" size=2>this</font><font size=2>.MailMesaji.To.Add(</font><font color="#0000ff" size=2>new</font><b><font size=2> </b></font><font color="#008080" size=2>MailAddress</font><b><font size=2>(</b></font><font color="#800000" size=2>&quot;to mail adress&quot;</font><b><font size=2>));</p></b><b> <p>System.Net.Mail.</b></font><font color="#008080" size=2>SmtpClient</font><b><font size=2> Smtp = </b></font><font color="#0000ff" size=2>new</font><b><font size=2> </b></font><font color="#008080" size=2>SmtpClient</font><b><font size=2>();</p> <p>Smtp.Host = </b></font><font color="#800000" size=2>&quot;smtp.gmail.com&quot;</font><b><font size=2>; </b></font><font color="#008000" size=2>// for example gmail smtp server</p></font><b><font size=2> <p>Smtp.EnableSsl = </b></font><font color="#0000ff" size=2>true</font><b><font size=2>;</p> <p>Smtp.Credentials = </b></font><font color="#0000ff" size=2>new</font><b><font size=2> System.Net.</b></font><font color="#008080" size=2>NetworkCredential</font><b><font size=2>(</b></font><font color="#800000" size=2>&quot;account name&quot;</font><b><font size=2>, </b></font><font color="#800000" size=2>&quot;password&quot;</font><b><font size=2>);</p> <p>Smtp.Send(MailMesaji);</p> <p></p> <p></p> <p>}</p> <p> </p> <p> </p> <p>it is required that you have to enable smtp service from your mail settings.. (for gmail you also enable ssl option.)</p> <p>is it enough ???</p></b></font>Fri, 17 Mar 2006 16:23:18 Z2006-03-17T16:23:18Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#2d1ac296-00af-49c2-8a71-bd346d0ec1f8http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#2d1ac296-00af-49c2-8a71-bd346d0ec1f8Amr Nourhttp://social.msdn.microsoft.com/Profile/en-US/?user=Amr%20NourHow do I send mail using C#?<P>I'm just trying&nbsp;this code but it doesn't working</P> <P>the error messege is "The remote server returned an error: (403) Forbidden.</P> <P>i was trying to change the draft code <FONT color=#008000 size=2></P> <P>//string draftsUri = "http://" + server + "/" + mailbox + "/drafts/" + subject + ".eml";</P> <P>to</P><FONT color=#0000ff size=2> <P>string</FONT><FONT size=2><FONT color=#000000> draftsUri = httpProtocol + server + "/" + mailbox + "/drafts/" + subject + ".eml";</FONT></FONT></P> <P><FONT size=2><FONT color=#000000>to use the secure HTTP </FONT></FONT></P> <P><FONT size=2><FONT color=#000000>it also returned this error "The function completed successfully, but must be called again to complete the context"</FONT></FONT></P> <P><FONT size=2><FONT color=#000000>Any Help .....</FONT></P></FONT></FONT>Thu, 23 Mar 2006 11:40:11 Z2006-03-23T11:40:11Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ece1e241-ee4f-4b62-bfdb-c7e961904d0chttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ece1e241-ee4f-4b62-bfdb-c7e961904d0cnickgroverhttp://social.msdn.microsoft.com/Profile/en-US/?user=nickgroverHow do I send mail using C#?<p>This code has really worked well for me, but I am having some issues in getting it to work over https as we are using a self published certificate.  I am using the following code to supposedly trust all certificates, but I am still getting an 401 unauthorized error.  I don't get this error when I use it over http, and I know that the exchange server is set up for https as that is how our Outlook Web is running.</p><font color="#0000ff" size=2> <p>public</font><font size=2> </font><font color="#0000ff" size=2>class</font><font size=2> </font><font color="#008080" size=2>TrustAllCertificatePolicy</font><font size=2> : </font><font color="#008080" size=2>ICertificatePolicy</p></font><font size=2> <p>{</p> <p></font><font color="#0000ff" size=2>public</font><font size=2> TrustAllCertificatePolicy()</p> <p>{ }</p></font><font color="#0000ff" size=2> <p>#region</font><font size=2> ICertificatePolicy Members</p> <p></font><font color="#0000ff" size=2>bool</font><font size=2> </font><font color="#008080" size=2>ICertificatePolicy</font><font size=2>.CheckValidationResult(</font><font color="#008080" size=2>ServicePoint</font><font size=2> srvPoint, </font><font color="#008080" size=2>X509Certificate</font><font size=2> certificate, </font><font color="#008080" size=2>WebRequest</font><font size=2> request, </font><font color="#0000ff" size=2>int</font><font size=2> certificateProblem)</p> <p>{</p> <p></font><font color="#0000ff" size=2>return</font><font size=2> </font><font color="#0000ff" size=2>true</font><font size=2>;</p> <p>}</p></font><font color="#0000ff" size=2> <p>#endregion</p></font><font size=2> <p>}</p></font> <p>I have heard that this is now obsolete in .NET 2.0.  If this is the case, what should be used, and how should it be used.</p>Thu, 30 Mar 2006 00:00:58 Z2006-03-30T00:00:58Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#0c362e16-b679-40c0-a5c7-6de66bcf7152http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#0c362e16-b679-40c0-a5c7-6de66bcf7152ByoBluhttp://social.msdn.microsoft.com/Profile/en-US/?user=ByoBluHow do I send mail using C#?<p>&gt;is it enough ???</p> <p> LOL <img src="images/emoticons/smile_regular.gif"></p> <p>I hope it is, ...I will try in a few moment.</p> <p>Bye</p>Sat, 08 Apr 2006 18:18:41 Z2006-04-08T18:18:41Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#613cdf6a-2abb-424f-a965-d3677ebb6779http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#613cdf6a-2abb-424f-a965-d3677ebb6779ByoBluhttp://social.msdn.microsoft.com/Profile/en-US/?user=ByoBluHow do I send mail using C#?<p>Unfortunately, it does not work.</p> <p>After 100 seconds an operation timeout exception is thrown (it is an smtpException).</p> <p>Here is the code:</p> <p> </p><font size=2> <p></font><font face="Courier New, Courier, Monospace" color="#0000ff" size=2>if</font><font size=2><font face="Courier New, Courier, Monospace">(_toAddresses.Count==0)</font></p> <p></font><font face="Courier New, Courier, Monospace"><font color="#0000ff" size=2>throw</font><font size=2> </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>EmailNotifierException</font><font size=2>(</font><font color="#0000ff" size=2>this</font><font size=2>,n,</font><font color="#800000" size=2>&quot;No recipients specified.&quot;</font></font><font size=2><font face="Courier New, Courier, Monospace">);</font></p> <p><font face="Courier New, Courier, Monospace"></font></p> <p></font><font face="Courier New, Courier, Monospace"><font color="#008080" size=2>SmtpClient</font><font size=2> smtpClient = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>SmtpClient</font></font><font size=2><font face="Courier New, Courier, Monospace">();</font></p> <p><font face="Courier New, Courier, Monospace">smtpClient.DeliveryMethod = </font></font><font face="Courier New, Courier, Monospace" color="#008080" size=2>SmtpDeliveryMethod</font><font size=2><font face="Courier New, Courier, Monospace">.Network;</font></p> <p><font face="Courier New, Courier, Monospace">smtpClient.Timeout = _smtpTimeoutMilliseconds;</font></p> <p></font><font face="Courier New, Courier, Monospace" color="#0000ff" size=2>if</font><font size=2><font face="Courier New, Courier, Monospace"> (_smtpServer.Length == 0) </font></p> <p></font><font face="Courier New, Courier, Monospace"><font color="#0000ff" size=2>throw</font><font size=2> </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>EmailNotifierException</font><font size=2>(</font><font color="#0000ff" size=2>this</font><font size=2>,n,</font><font color="#800000" size=2>&quot;SMTP Server not specified&quot;</font></font><font size=2><font face="Courier New, Courier, Monospace">);</font></p> <p><font face="Courier New, Courier, Monospace">smtpClient.Host = _smtpServer;</font></p> <p><font face="Courier New, Courier, Monospace">smtpClient.Port = _smtpPort;</font></p> <p></font><font face="Courier New, Courier, Monospace" color="#0000ff" size=2>if</font><font size=2><font face="Courier New, Courier, Monospace"> (_username.Length &gt; 0 &amp;&amp; _userpassword.Length &gt; 0)</font></p> <p><font face="Courier New, Courier, Monospace">smtpClient.Credentials = </font></font><font face="Courier New, Courier, Monospace"><font color="#0000ff" size=2>new</font><font size=2> System.Net.</font><font color="#008080" size=2>NetworkCredential</font></font><font size=2><font face="Courier New, Courier, Monospace">(_username, _userpassword);</font></p> <p></font><font face="Courier New, Courier, Monospace" color="#0000ff" size=2>if</font><font size=2><font face="Courier New, Courier, Monospace"> (_SSL)</font></p> <p><font face="Courier New, Courier, Monospace">smtpClient.EnableSsl = </font></font><font face="Courier New, Courier, Monospace" color="#0000ff" size=2>true</font><font size=2><font face="Courier New, Courier, Monospace">;</font></p> <p></font><font color="#0000ff" size=2><font face="Courier New, Courier, Monospace">else</font></p></font><font size=2> <p><font face="Courier New, Courier, Monospace">smtpClient.EnableSsl = </font></font><font face="Courier New, Courier, Monospace" color="#0000ff" size=2>false</font><font size=2><font face="Courier New, Courier, Monospace">;</font></p> <p></font><font face="Courier New, Courier, Monospace"><font color="#008080" size=2>MailMessage</font><font size=2> mail = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>MailMessage</font></font><font size=2><font face="Courier New, Courier, Monospace">();</font></p> <p><font face="Courier New, Courier, Monospace">mail.From = </font></font><font face="Courier New, Courier, Monospace"><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>MailAddress</font></font><font size=2><font face="Courier New, Courier, Monospace">(_fromAddress,_fromName);</font></p> <p></font><font face="Courier New, Courier, Monospace"><font color="#0000ff" size=2>foreach</font><font size=2> (</font><font color="#008080" size=2>MailAddress</font><font size=2> a </font><font color="#0000ff" size=2>in</font></font><font size=2><font face="Courier New, Courier, Monospace"> _toAddresses)</font></p> <p><font face="Courier New, Courier, Monospace">mail.To.Add(a);</font></p> <p></font><font face="Courier New, Courier, Monospace"><font color="#0000ff" size=2>foreach</font><font size=2> (</font><font color="#008080" size=2>MailAddress</font><font size=2> a </font><font color="#0000ff" size=2>in</font></font><font size=2><font face="Courier New, Courier, Monospace"> _ccAddresses)</font></p> <p><font face="Courier New, Courier, Monospace">mail.CC.Add(a);</font></p> <p></font><font face="Courier New, Courier, Monospace"><font color="#0000ff" size=2>foreach</font><font size=2> (</font><font color="#008080" size=2>MailAddress</font><font size=2> a </font><font color="#0000ff" size=2>in</font></font><font size=2><font face="Courier New, Courier, Monospace"> _bccAddresses)</font></p> <p><font face="Courier New, Courier, Monospace">mail.Bcc.Add(a);</font></p> <p><font face="Courier New, Courier, Monospace">mail.IsBodyHtml = </font></font><font face="Courier New, Courier, Monospace" color="#0000ff" size=2>false</font><font size=2><font face="Courier New, Courier, Monospace">;</font></p> <p><font face="Courier New, Courier, Monospace">mail.Priority = (</font></font><font face="Courier New, Courier, Monospace" color="#008080" size=2>MailPriority</font><font size=2><font face="Courier New, Courier, Monospace">) _priority;</font></p> <p><font face="Courier New, Courier, Monospace">mail.Subject = _subjectPrefix + </font></font><font face="Courier New, Courier, Monospace"><font color="#800000" size=2>&quot; &quot;</font><font size=2> + _name + </font><font color="#800000" size=2>&quot; notification.&quot;</font></font><font size=2><font face="Courier New, Courier, Monospace">;</font></p> <p><font face="Courier New, Courier, Monospace">mail.DeliveryNotificationOptions = (</font></font><font face="Courier New, Courier, Monospace" color="#008080" size=2>DeliveryNotificationOptions</font><font size=2><font face="Courier New, Courier, Monospace">)_deliveryNotification;</font></p> <p><font face="Courier New, Courier, Monospace">mail.Body = createTextBody(n);</font></p> <p><font face="Courier New, Courier, Monospace">smtpClient.SendCompleted += </font></font><font face="Courier New, Courier, Monospace"><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>SendCompletedEventHandler</font></font><font size=2><font face="Courier New, Courier, Monospace">(SendCompletedCallback);</font></p> <p></font><font color="#0000ff" size=2><font face="Courier New, Courier, Monospace">try</font></p></font><font size=2> <p><font face="Courier New, Courier, Monospace">{</font></p> <p></font><font face="Courier New, Courier, Monospace" color="#0000ff" size=2>if</font><font size=2><font face="Courier New, Courier, Monospace"> (_aSyinc)</font></p> <p><font face="Courier New, Courier, Monospace">smtpClient.SendAsync(mail, n);</font></p> <p></font><font color="#0000ff" size=2><font face="Courier New, Courier, Monospace">else</font></p></font><font size=2> <p><font face="Courier New, Courier, Monospace">smtpClient.Send(mail);</font></p> <p><font face="Courier New, Courier, Monospace">}</font></p> <p></font><font face="Courier New, Courier, Monospace"><font color="#0000ff" size=2>catch</font><font size=2> (</font><font color="#008080" size=2>SmtpException</font><font size=2> exc) { </font><font color="#0000ff" size=2>throw</font><font size=2> </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>EmailNotifierException</font><font size=2>(</font><font color="#0000ff" size=2>this</font></font><font size=2><font face="Courier New, Courier, Monospace">, n, exc.Message); }</font></p> <p></font><font face="Courier New, Courier, Monospace"><font color="#0000ff" size=2>catch</font><font size=2> (</font><font color="#008080" size=2>Exception</font><font size=2> exc) { </font><font color="#0000ff" size=2>throw</font><font size=2> </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>EmailNotifierException</font><font size=2>(</font><font color="#0000ff" size=2>this</font><font size=2>, n, exc.Message); }</p></font></font> <p> </p>Sat, 08 Apr 2006 20:15:47 Z2006-04-08T20:15:47Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#fa78ad6c-f53f-48ce-b4d0-12294ce83b2ahttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#fa78ad6c-f53f-48ce-b4d0-12294ce83b2aAmr Nourhttp://social.msdn.microsoft.com/Profile/en-US/?user=Amr%20NourHow do I send mail using C#?<p>i'm succeeded to connect to Exchange server as SMTP </p> <p>not need this code just use the simple smtp code and go on</p>Mon, 10 Apr 2006 08:50:23 Z2006-04-10T08:50:23Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#18640c48-0df1-4d19-9e31-e29828c829c9http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#18640c48-0df1-4d19-9e31-e29828c829c9Pepepacohttp://social.msdn.microsoft.com/Profile/en-US/?user=PepepacoHow do I send mail using C#?<p> </p> <p>//<font face="Courier New" color="#0000ff" size=2>For VS2003 Add the COM “Microsoft CDO for Windows 2000 Library” reference</font></p><font color="#0000ff" size=2> <p>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> CDOSendCC(</font><font color="#0000ff" size=2>string</font><font size=2> from, </font><font color="#0000ff" size=2>string</font><font size=2> Recipients, </font><font color="#0000ff" size=2>string</font><font size=2> RecipientsCC, </font><font color="#0000ff" size=2>string</font><font size=2> url, </font><font color="#0000ff" size=2>string</font><font size=2> Subject, </font><font color="#0000ff" size=2>string</font><font size=2> user, </font><font color="#0000ff" size=2>string</font><font size=2> password)</p> <p>{</p> <p></font><font color="#0000ff" size=2>try</p></font><font size=2> <p>{</p> <p>CDO.MessageClass Message = </font><font color="#0000ff" size=2>new</font><font size=2> CDO.MessageClass();</p> <p>CDO.ConfigurationClass iConf = </font><font color="#0000ff" size=2>new</font><font size=2> CDO.ConfigurationClass();</p> <p>iConf.Fields[CDO.CdoConfiguration.cdoSendUsingMethod].Value = CDO.CdoSendUsing.cdoSendUsingPort;</p> <p>iConf.Fields[CDO.CdoConfiguration.cdoSMTPServer].Value = </font><font color="#800000" size=2>&quot;smtpServer&quot;</font><font size=2>;</p> <p>iConf.Fields[CDO.CdoConfiguration.cdoSMTPAuthenticate].Value = CDO.CdoProtocolsAuthentication.cdoBasic;</p> <p>iConf.Fields[CDO.CdoConfiguration.cdoSendUserName].Value = user;</p> <p>iConf.Fields[CDO.CdoConfiguration.cdoSendPassword].Value = password;</p> <p>iConf.Fields.Update();</p> <p>Message.Configuration = iConf;</p> <p>Message.From = from;</p> <p>Message.To = Recipients;</p> <p>Message.CC = RecipientsCC;</p> <p>Message.Subject = Subject;</p> <p>Message.CreateMHTMLBody(url, CDO.CdoMHTMLFlags.cdoSuppressAll, </font><font color="#800000" size=2>&quot;&quot;</font><font size=2>, </font><font color="#800000" size=2>&quot;&quot;</font><font size=2>);</p> <p>Message.Send();</p> <p>}</p> <p></font><font color="#0000ff" size=2>catch</font><font size=2> (System.Web.HttpException ehttp)</p> <p>{</p> <p></font><font color="#008080" size=2>Console</font><font size=2>.Write(ehttp.Message);</p> <p></font><font color="#008080" size=2>Console</font><font size=2>.Write(ehttp.InnerException.Message);</p> <p>}</p> <p></font><font color="#0000ff" size=2>catch</font><font size=2> (System.</font><font color="#008080" size=2>Exception</font><font size=2> ex)</p> <p>{</p> <p></font><font color="#008080" size=2>Console</font><font size=2>.Write(ex.Message);</p> <p>}</p> <p>}</p></font> <p> </p> <p>//VS2005 Use the follow</p><font color="#0000ff" size=2> <p>private</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> SendMail()</font></p> <p><font size=2>{</p> <p>System.Net.Mail.</font><font color="#008080" size=2>MailMessage</font><font size=2> message = </font><font color="#0000ff" size=2>new</font><font size=2> System.Net.Mail.</font><font color="#008080" size=2>MailMessage</font><font size=2>();</p> <p></p> <p>message.To.Add(</font><font color="#800000" size=2>&quot;somemail@domain.com&quot;</font><font size=2>);</p> <p>message.CC.Add(</font><font color="#800000" size=2>&quot;someothermail@domain.com&quot;</font><font size=2>);</p> <p>message.Subject = </font><font color="#800000" size=2>&quot;This is the Subject line&quot;</font><font size=2>;</p> <p>message.From = </font><font color="#0000ff" size=2>new</font><font size=2> System.Net.Mail.</font><font color="#008080" size=2>MailAddress</font><font size=2>(</font><font color="#800000" size=2>&quot;frommail@domain.com&quot;</font><font size=2>);</p> <p></p> <p>System.IO.</font><font color="#008080" size=2>TextReader</font><font size=2> txtRead = </font><font color="#0000ff" size=2>new</font><font size=2> System.IO.</font><font color="#008080" size=2>StreamReader</font><font size=2>(</font><font color="#800000" size=2>@&quot;D:\Attachments\Directory\CM-ODM Directory\13 06\checksum.txt&quot;</font><font size=2>);</p> <p>message.Body = txtRead.ReadToEnd();</p> <p></p> <p>System.Net.Mail.</font><font color="#008080" size=2>SmtpClient</font><font size=2> smtp = </font><font color="#0000ff" size=2>new</font><font size=2> System.Net.Mail.</font><font color="#008080" size=2>SmtpClient</font><font size=2>(</font><font color="#800000" size=2>&quot;smtpServer&quot;</font><font size=2>,25); </p> <p>smtp.Credentials = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>NetworkCredential</font><font size=2>(</font><font color="#800000" size=2>&quot;username&quot;</font><font size=2>, </font><font color="#800000" size=2>&quot;password&quot;</font><font size=2>);</p> <p>smtp.Send(message);</p> <p>}</p> <p> </p></font>Mon, 10 Apr 2006 21:47:10 Z2006-04-10T21:47:10Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#98e06144-efb6-4768-bdd9-5f65365bc8a6http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#98e06144-efb6-4768-bdd9-5f65365bc8a6Valentin2http://social.msdn.microsoft.com/Profile/en-US/?user=Valentin2How do I send mail using C#?<p><span lang=EN-GB style="font-size:18pt;color:black;font-family:'Times New Roman'"><font size=3>Of course I am not the alone one who sent you a similar code, but I wish to emphasize how to enter the parameter <em><strong>SmtpMail.SmtpServer</strong></em> in case of a mail from a server. The value &quot;localhost&quot; is a place holder for the address of the mail server. You can use it as well, i.e. you do not need to know the really address of the mail server.</font></span></p> <p>  public void SendMail(string subject, string body)<br>  {<br>   MailMessage MyMail = new MailMessage();<br>   SmtpMail.SmtpServer = &quot;localhost&quot;;   // from server<br>    // or<br>   SmtpMail.SmtpServer = &quot;mailto.t-online.de&quot;;  // example from local PC  </p> <p>   MyMail.From = &quot;<a title="mailto:wwv-it@wwv-it.com" href="mailto:wwv-it@wwv-it.com">mail address</a>&quot;;<br>   MyMail.To = &quot;<a title="mailto:valentin.welter@t-online.de" href="mailto:valentin.welter@t-online.de">mail address</a>&quot;;<br>   MyMail.Subject = subject;<br>   MyMail.Body = body;  <br>   SmtpMail.Send(MyMail);<br>  }<br></p> <p style="background:white"><span lang=EN-GB style="color:black;font-family:'Times New Roman'">Have a fun!</span></p> <p style="background:white"><span lang=EN-GB style="color:black;font-family:'Times New Roman'">Valentin </span></p> <p style="background:white"><span lang=EN-GB style="color:black;font-family:'Times New Roman'">Do not hesitate to contact me!</span></p> <p><span lang=EN-GB style="font-size:12pt;color:black;font-family:'Times New Roman'"><a title="http://www.wwv-it.eu/" href="http://www.wwv-it.eu/"><u><font color="#800080">www.wwv-it.eu</font></u></a></span></p> <p> </p>Fri, 21 Apr 2006 00:12:18 Z2006-04-21T00:12:18Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#46bff84c-63aa-4a7a-ba35-81c18d31d821http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#46bff84c-63aa-4a7a-ba35-81c18d31d821Anand Prakashhttp://social.msdn.microsoft.com/Profile/en-US/?user=Anand%20PrakashHow do I send mail using C#?<p><font face="Tahoma,Helvetica,Sans-Serif" size=2>I have a similar requirement where I need to send mail via exchange server. Can yo tell me how did you connect to exchange server as SMTP?</font></p> <p><font face="Tahoma,Helvetica,Sans-Serif" size=2>Thanks in advance!</font></p> <p><font face="Tahoma,Helvetica,Sans-Serif" size=2>Anand.</font></p>Fri, 26 May 2006 13:53:56 Z2006-05-26T13:53:56Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3617852e-989b-455c-bcce-be3288de7f8ahttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3617852e-989b-455c-bcce-be3288de7f8aChatterEmailhttp://social.msdn.microsoft.com/Profile/en-US/?user=ChatterEmailHow do I send mail using C#?The PUT / MOVE method of sending mail via WebDAV works well for IIS/6.0 servers, but in my experience the MOVE fails with IIS/5.0 servers.   Has anyone seen this, or have an idea what's going on?<br><br>Marc<br>Fri, 02 Jun 2006 05:13:22 Z2006-06-02T05:13:22Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#9c79bc18-c02c-42e2-b4c8-fc138d52b406http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#9c79bc18-c02c-42e2-b4c8-fc138d52b406Pepepacohttp://social.msdn.microsoft.com/Profile/en-US/?user=PepepacoHow do I send mail using C#?<p><span style="font-size:9.5pt;color:black"><font face="Times New Roman">what is the error message </font><a id="_ctl0_MainContent__ctl0_PostForm_ReplyPostedBy" href="http://forums.microsoft.com/MSDN/User/Profile.aspx?UserID=177417&amp;SiteID=1"><strong><span style="color:#013da4;text-decoration:none;text-underline:none"><font face="Times New Roman">ChatterEmail</font></span></strong></a><font face="Times New Roman">??, webdav is installed in IIS 5.0 by default, so maybe you are having security error, I was having some &quot;no relay&quot; problems using programmatically authentication so  if it is you case try using the App.config to declare the Credentials, I don’t know why putting credentials in App.Config works better than using programmatically, but it appends to me. Here is an example:</font></span></span><span style="font-size:10pt;color:blue;font-family:'Courier New'"><span style="">  </span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;color:blue;font-family:'Courier New'">&lt;</span><span style="font-size:10pt;color:maroon;font-family:'Courier New'">system.net</span><span style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;color:blue;font-family:'Courier New'"><span style="">    </span>&lt;</span><span style="font-size:10pt;color:maroon;font-family:'Courier New'">mailSettings</span><span style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;color:blue;font-family:'Courier New'"><span style="">      </span>&lt;</span><span style="font-size:10pt;color:maroon;font-family:'Courier New'">smtp</span><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span><span style="font-size:10pt;color:red;font-family:'Courier New'">from</span><span style="font-size:10pt;color:blue;font-family:'Courier New'">=</span><span style="font-size:10pt;font-family:'Courier New'">&quot;<span style="color:blue">yoursenderemail@corporate.com</span>&quot;<span style="color:blue">&gt;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;color:blue;font-family:'Courier New'"><span style="">        </span>&lt;</span><span style="font-size:10pt;color:maroon;font-family:'Courier New'">network</span><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span><span style="font-size:10pt;color:red;font-family:'Courier New'">host</span><span style="font-size:10pt;color:blue;font-family:'Courier New'">=</span><span style="font-size:10pt;font-family:'Courier New'">&quot;<span style="color:blue">hostname</span>&quot;<span style="color:blue"> </span><span style="color:red">password</span><span style="color:blue">=</span>&quot;<span style="color:blue">Password</span>&quot;<span style="color:blue"> </span><span style="color:red">userName</span><span style="color:blue">=</span>&quot;<span style="color:blue">exchangeuserID</span>&quot;<span style="color:blue"> /&gt;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;color:blue;font-family:'Courier New'"><span style="">      </span>&lt;/</span><span style="font-size:10pt;color:maroon;font-family:'Courier New'">smtp</span><span style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;color:blue;font-family:'Courier New'"><span style="">    </span>&lt;/</span><span style="font-size:10pt;color:maroon;font-family:'Courier New'">mailSettings</span><span style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;color:blue;font-family:'Courier New'"><span style="">  </span>&lt;/</span><span style="font-size:10pt;color:maroon;font-family:'Courier New'">system.net</span><span style="font-size:10pt;color:blue;font-family:'Courier New'">&gt;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;color:blue;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:9.5pt;color:black"><font face="Times New Roman">*Note that the username is the user you use to log in through Outlook, not your Alias to send email.</font></span></p> <p> <p> </p></p>Fri, 02 Jun 2006 13:25:48 Z2006-06-02T13:25:48Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#79620a36-a7b3-4f50-9eee-c2c949132b04http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#79620a36-a7b3-4f50-9eee-c2c949132b04ChatterEmailhttp://social.msdn.microsoft.com/Profile/en-US/?user=ChatterEmailHow do I send mail using C#?The strange thing is that there is no error; my app just never gets a reply to the MOVE (I get a 100 Continue and then a 201 Created for the PUT).   Is it possible that IIS/5.0 is closing the connection after a PUT and I need to re-open it?   My code works perfectly on all IIS/6.0 systems as is (i.e. I assume the HTTP connection remains open).<br><br>Marc<br>Fri, 02 Jun 2006 16:59:22 Z2006-06-02T16:59:22Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ac41faf4-fa04-4129-8d7f-9cd70f5cba4fhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ac41faf4-fa04-4129-8d7f-9cd70f5cba4fPepepacohttp://social.msdn.microsoft.com/Profile/en-US/?user=PepepacoHow do I send mail using C#?<p><a id="_ctl0_MainContent__ctl0_PostForm_ReplyPostedBy" href="http://forums.microsoft.com/MSDN/User/Profile.aspx?UserID=177417&amp;SiteID=1"><strong>ChatterEmail</strong></a>, it will be very dificult to figure out whats hapening with out doing some research first, enable logging for IIS, if there is no error message, try to reproduce the error on an isolated environtment, try to send the email using CDONTS to see if it work, check if you have access to the inbox, attachments etc.;...... Im using this function to search for unread items, download all their attachments and then mark them as read to not to catch them again... hope this can help you.</p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;color:blue;font-family:'Courier New'">//VS2005, <span style="font-size:12pt;font-family:'Times New Roman'"><font color="#000000"><span style="font-size:10pt;color:blue;font-family:'Courier New'">slightly </span></font></span>modified microsoft code</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;color:blue;font-family:'Courier New'">public</span><span style="font-size:10pt;font-family:'Courier New'"> <span style="color:blue">static</span> <span style="color:blue">void</span> BrowseInbox(<span style="color:blue">string</span> path, <span style="color:blue">string</span> server, <span style="color:blue">string</span> user,<span style="color:blue">string</span> userid,<span style="color:blue">string</span> password)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">        </span>{</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:green">// Variables.</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>System.Net.<span style="color:teal">HttpWebRequest</span> Request;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>System.Net.<span style="color:teal">WebResponse</span> Response;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">string</span> strRootURI = <span style="color:maroon">&quot;http://&quot;</span> + server + <span style="color:maroon">&quot;/Exchange/&quot;</span> + user + <span style="color:maroon">&quot;/inbox/&quot;</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">string</span> strUserName = userid;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">string</span> strPassword = password;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">string</span> strDomain = <span style="color:maroon">&quot;domain&quot;</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">string</span> strQuery = <span style="color:maroon">&quot;&quot;</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">byte</span>[] bytes = <span style="color:blue">null</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>System.IO.<span style="color:teal">Stream</span> RequestStream = <span style="color:blue">null</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>System.IO.<span style="color:teal">Stream</span> ResponseStream = <span style="color:blue">null</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:teal">XmlDocument</span> ResponseXmlDoc = <span style="color:blue">null</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:teal">XmlNodeList</span> DisplayNameNodes = <span style="color:blue">null</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"> </span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style=""> </span><span style="">           </span>strQuery = <span style="color:maroon">&quot;&lt;?xml version=\&quot;1.0\&quot;?&gt;&lt;D:searchrequest xmlns:D = \&quot;DAV:\&quot; &gt;&quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>+ <span style="color:maroon">&quot;&lt;D:sql&gt;select &quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>+ <span style="color:maroon">&quot;\&quot;urn:schemas:httpmail:fromemail\&quot;&quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>+ <span style="color:maroon">&quot;, \&quot;urn:schemas:httpmail:read\&quot;&quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>+ <span style="color:maroon">&quot; from scope ('shallow traversal of &quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>+ (<span style="color:blue">char</span>)(34) + strRootURI + (<span style="color:blue">char</span>)(34) + <span style="color:maroon">&quot;') WHERE \&quot;urn:schemas:httpmail:read\&quot; = false AND \&quot;urn:schemas:httpmail:hasattachment\&quot; = true &quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>+ <span style="color:maroon">&quot;<span style="">  </span>&lt;/D:sql&gt;&lt;/D:searchrequest&gt;&quot;</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>System.Net.<span style="color:teal">CredentialCache</span> MyCredentialCache;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>MyCredentialCache = <span style="color:blue">new</span> System.Net.<span style="color:teal">CredentialCache</span>();</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>MyCredentialCache.Add(<span style="color:blue">new</span> System.<span style="color:teal">Uri</span>(strRootURI), <span style="color:maroon">&quot;NTLM&quot;</span>, <span style="color:blue">new</span> <span style="color:teal">NetworkCredential</span>(strUserName,strPassword,strDomain));</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>Request = (System.Net.<span style="color:teal">HttpWebRequest</span>)<span style="color:teal">HttpWebRequest</span>.Create(strRootURI);</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>Request.Credentials = MyCredentialCache;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>Request.Method = <span style="color:maroon">&quot;SEARCH&quot;</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>bytes = <span style="color:teal">Encoding</span>.UTF8.GetBytes((<span style="color:blue">string</span>)strQuery);</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>Request.ContentLength = bytes.Length;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>Request.Timeout = 600000;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>RequestStream = Request.GetRequestStream();</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>RequestStream.Write(bytes, 0, bytes.Length);</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>RequestStream.Close();</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>Request.ContentType = <span style="color:maroon">&quot;text/xml&quot;</span>;</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>Response = (<span style="color:teal">HttpWebResponse</span>)Request.GetResponse();</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>ResponseStream = Response.GetResponseStream();</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>ResponseXmlDoc = <span style="color:blue">new</span> <span style="color:teal">XmlDocument</span>();</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>ResponseXmlDoc.Load(ResponseStream);</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>DisplayNameNodes = ResponseXmlDoc.GetElementsByTagName(<span style="color:maroon">&quot;a:response&quot;</span>);</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">if</span> (DisplayNameNodes.Count &gt; 0)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>{</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span><span style="color:teal">Console</span>.WriteLine(<span style="color:maroon">&quot;Non-folder item display names...&quot;</span>);</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span><span style="color:blue">for</span> (<span style="color:blue">int</span> i = 0; i &lt; DisplayNameNodes.Count; i++)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>{</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                    </span>SetRead(DisplayNameNodes<img src="/MSDN//emoticons/emotion-55.gif" alt=Idea>[<span style="color:maroon">&quot;a:href&quot;</span>].InnerXml, <span style="color:blue">new</span> <span style="color:teal">NetworkCredential</span>(strUserName, strPassword,strDomain));</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                    </span>ReadAttach(DisplayNameNodes<img src="/MSDN//emoticons/emotion-55.gif" alt=Idea>[<span style="color:maroon">&quot;a:href&quot;</span>].InnerXml, path, DisplayNameNodes<img src="/MSDN//emoticons/emotion-55.gif" alt=Idea>[<span style="color:maroon">&quot;a:propstat&quot;</span>].GetElementsByTagName(<span style="color:maroon">&quot;a:prop&quot;</span>)[0][<span style="color:maroon">&quot;d:fromemail&quot;</span>].InnerText, <span style="color:blue">new</span> <span style="color:teal">NetworkCredential</span>(strUserName, strPassword, strDomain));</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span>}</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>}</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span><span style="color:blue">else</span></span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>{</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">                </span><span style="color:teal">Console</span>.WriteLine(<span style="color:maroon">&quot;No non-folder items found...&quot;</span>);</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>}</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>ResponseStream.Close();</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">            </span>Response.Close();</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:10pt;font-family:'Courier New'"><span style="">        </span>}</span></p> <p> <p> </p> <p></p>Fri, 02 Jun 2006 22:35:57 Z2006-06-02T22:35:57Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#948bf8f1-dfe7-4b0d-91e7-2dd63c103845http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#948bf8f1-dfe7-4b0d-91e7-2dd63c103845EthanShttp://social.msdn.microsoft.com/Profile/en-US/?user=EthanSHow do I send mail using C#?<p>Hi,</p> <p>I was attempting to do the same thing earlier, using similar code. I also tried code suggested in Microsoft's help files for this purpose. However, when I attempt to send e-mail it claims that the host is refusing it. The Microsoft code that I tried is as follows:</p><pre>using System; using System.Web.Mail; namespace SendMail { class usage { public void DisplayUsage() { Console.WriteLine(&quot;Usage SendMail.exe &lt;to&gt; &lt;from&gt; &lt;subject&gt; &lt;body&gt;&quot;); Console.WriteLine(&quot;&lt;to&gt; the addresses of the email recipients&quot;); Console.WriteLine(&quot;&lt;from&gt; your email address&quot;); Console.WriteLine(&quot;&lt;subject&gt; subject of your email&quot;); Console.WriteLine(&quot;&lt;body&gt; the text of the email&quot;); Console.WriteLine(&quot;Example:&quot;); Console.WriteLine(&quot;SendMail.exe SomeOne@Contoso.com;SomeOther@Contoso.com Me@contoso.com Hi hello&quot;); } } class Start { // The main entry point for the application. [STAThread] static void Main(string[] args) { try { try { MailMessage Message = new MailMessage(); Message.To = args[0]; Message.From = args[1]; Message.Subject = args[2]; Message.Body = args[3]; try { SmtpMail.SmtpServer = &quot;your mail server name goes here&quot;; SmtpMail.Send(Message); } catch(System.Web.HttpException ehttp) { Console.WriteLine(&quot;{0}&quot;, ehttp.Message); Console.WriteLine(&quot;Here is the full error message output&quot;); Console.Write(&quot;{0}&quot;, ehttp.ToString()); } } catch(IndexOutOfRangeException) { usage use = new usage(); use.DisplayUsage(); } } catch(System.Exception e) { Console.WriteLine(&quot;Unknown Exception occurred {0}&quot;, e.Message); Console.WriteLine(&quot;Here is the Full Message output&quot;); Console.WriteLine(&quot;{0}&quot;, e.ToString()); } } } } </pre><pre>(Obviously I inserted the appropriate mail server). Here is the exact error message the program gives me when I run it:</pre><pre><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'">Exception occurred Failure sending mail.</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'">Here is the full message output:</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'">System.Net.Mail.SmtpException: Failure sending mail. ---&gt; System.Net.WebExceptio</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'">n: Unable to connect to the remote server ---&gt; System.Net.Sockets.SocketExceptio</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'">n: An established connection was aborted by the software in your host machine</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddre</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'">ss socketAddress)</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Sock</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'">et s4, Socket s6, Socket&amp; socket, IPAddress&amp; address, ConnectSocketState state,</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'">IAsyncResult asyncResult, Int32 timeout, Exception&amp; exception)</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>--- End of inner exception stack trace ---</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object ow</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'">ner, Boolean async, IPAddress&amp; address, Socket&amp; abortSocket, Socket&amp; abortSocket</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'">6, Int32 timeout)</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style=""> </span>timeout, GeneralAsyncDelegate asyncCallback)</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style=""> </span>asyncCallback)</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncD</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'">elegate asyncCallback, Int32 creationTimeout)</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.Mail.SmtpClient.GetConnection()</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.Mail.SmtpClient.Send(MailMessage message)</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>--- End of inner exception stack trace ---</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at System.Net.Mail.SmtpClient.Send(MailMessage message)</span></p><p class=MsoNormal style="margin:0in 0.75pt 0pt 0in;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span style="font-size:14pt;color:#000066;font-family:'Courier New'"><span style="">   </span>at SendMail.Start.Main(String[] args) in C:\Ethan\Experimental\MailMessage\Ma</span></p><span style="font-size:14pt;color:#000066;font-family:'Courier New'">ilMessage\Program.cs:line 82</span></pre><pre> </pre><pre>I'm not sure if anyone has spoken to this issue yet or not, but I can't figure out how to get this to work to save m=y life.</pre><pre>I have tried both this code directly and several modifications of it, including using System.Net.Mail (with appropriate modifications).</pre><pre>Can anyone help me? The server I am using is a standard Windows server. I am able to ping it successfully. I am told by my network administrator that the same server can be used both as an exchange server and as a SMTP server. In addition, authentication is NOT necessary.</pre><pre>Any ideas on what I am doing wrong? I am at my whit's end in terms of why this is not working.</pre><pre> </pre><pre>Thanks,<br>Ethan S.</pre>Fri, 21 Jul 2006 13:44:28 Z2006-07-21T13:44:28Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#18487f45-5d92-4dcb-93ab-32bb191a7bc4http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#18487f45-5d92-4dcb-93ab-32bb191a7bc4Pepepacohttp://social.msdn.microsoft.com/Profile/en-US/?user=PepepacoHow do I send mail using C#?<p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:9.5pt;color:black;font-family:Verdana"><a id="_ctl0_MainContent__ctl0_PostForm_ReplyPostedBy" href="http://forums.microsoft.com/MSDN/User/Profile.aspx?UserID=227784&amp;SiteID=1"><strong>EthanS</strong></a>, Try some of the many examples in this forum; if they didn’t work probably it is a configuration issue in your server, if it is refusing connection probably the firewall is blocking the default port #25, you can also try to use servername instead of the IP address. </span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:9.5pt;color:black;font-family:Verdana"></span></span></p>Fri, 21 Jul 2006 14:30:58 Z2006-07-21T14:30:58Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#b754e3cb-d74e-44bf-bfa7-dbf614390350http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#b754e3cb-d74e-44bf-bfa7-dbf614390350tabishhttp://social.msdn.microsoft.com/Profile/en-US/?user=tabishHow do I send mail using C#?Try this Out:<br><br>using System;<br>using System.Net.Mail;<br><br>    class Mailer<br>    {<br>        enum MailMessagePart<br>        {<br>            From,<br>            To,<br>            Subject,<br>            Message<br>        }<br><br>        static void Main(string[] args)<br>        {<br>            if (args.Length &lt; 4)<br>            {    <br>                Console.WriteLine(<br>                    &quot;Expected: mailer.exe [from] [to] [subject] [message]&quot;);<br>                return;<br>            }<br><br>            // Set mailServerName to be the name of the mail server<br>            // you wish to use to deliver this message<br>            string mailServerName = &quot;smtphost&quot;;<br>            string from = args[(int) MailMessagePart.From];<br>            string to = args[(int) MailMessagePart.To];<br>            string subject = args[(int) MailMessagePart.Subject];<br>            string body = args[(int) MailMessagePart.Message];<br><br>            try<br>            {<br>                // MailMessage is used to represent the e-mail being sent<br>                using (MailMessage message = <br>                    new MailMessage(from, to, subject, body))<br>                {<br><br>                    // SmtpClient is used to send the e-mail<br>                    SmtpClient mailClient = new SmtpClient(mailServerName);<br><br>                    // UseDefaultCredentials tells the mail client to use the <br>                    // Windows credentials of the account (i.e. user account) <br>                    // being used to run the application<br>                    mailClient.UseDefaultCredentials = true;<br><br>                    // Send delivers the message to the mail server<br>                    mailClient.Send(message);<br>                }<br>                Console.WriteLine(&quot;Message sent.&quot;);<br>            }<br>            catch (FormatException ex)<br>            {<br>                Console.WriteLine(ex.Message);<br>            }<br>            catch (SmtpException ex)<br>            {<br>                Console.WriteLine(ex.Message);<br>            }<br>        }<br>    }<br><br>Fri, 28 Jul 2006 17:59:06 Z2006-07-28T17:59:06Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#47069c6e-ff08-4a49-be76-1db4146bfe21http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#47069c6e-ff08-4a49-be76-1db4146bfe21EthanShttp://social.msdn.microsoft.com/Profile/en-US/?user=EthanSHow do I send mail using C#?<p>Hi,</p> <p>I figured out what was wrong with my previous code. It was actually my virus scan (McAffee). Has anyone encountered this problem before? Is there a good way around that? I don't want to have to disable my virus software every time that I need to run this code.</p> <p>Thanks,<br>Ethan S.</p>Fri, 28 Jul 2006 20:04:06 Z2006-07-28T20:04:06Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#5927e22d-6076-4b48-bc29-d55e8613f6a4http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#5927e22d-6076-4b48-bc29-d55e8613f6a4Pepepacohttp://social.msdn.microsoft.com/Profile/en-US/?user=PepepacoHow do I send mail using C#?<a id="_ctl0_MainContent__ctl0_PostForm_ReplyPostedBy" href="http://forums.microsoft.com/MSDN/User/Profile.aspx?UserID=227784&amp;SiteID=1"><strong>EthanS</strong></a><span id="_ctl0_MainContent__ctl0_PostForm_ReplyPostedByDate"> <span style="font-size:9.5pt;color:black;font-family:Verdana">that's some weird, because Virus scan prevents to use port 25 in the server computer it is running, not at your local computer, probably it is blocking any new application trying to access internet, not only email, if this is the case, allow access to internet to your application using Virus scan console, <span style="font-size:9.5pt;color:black;font-family:Verdana">If you don’t have rights to do it, it will restore default settings every time you change it, ask you administrator about that.</span></span></span>Fri, 28 Jul 2006 20:41:30 Z2006-07-28T20:41:30Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#e6eb6c2a-da72-4cc1-a957-0e9bdadf2c39http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#e6eb6c2a-da72-4cc1-a957-0e9bdadf2c39blgnklchttp://social.msdn.microsoft.com/Profile/en-US/?user=blgnklcHow do I send mail using C#?<p>Hello,</p> <p>the basic problem: <font size=5>SmtpException was unhandled by user code Failure sending mail</font>. {working with asp net 2.0 and C#}</p> <p>When i want to  send an e mail i get the failure message you talked about. I ve been looking for solutions. i ve done these things below;</p> <p> everything is in <a title="http://www.codeproject.com/aspnet/techblaster.asp" href="http://www.codeproject.com/aspnet/techblaster.asp">http://www.codeproject.com/aspnet/techblaster.asp</a> i ve done and for summary;</p> <p>   </p> <h2><font size=3>Setting SMTP server</font></h2> <p>Before running the application you need to confirm these server settings:</p> <ol> <li>Make sure that the SMTP server is running, only then it can relay mail. If not, open the IIS window, in IIS look for the &quot;<i>local computer</i>&quot; on the left side tree view under which you will see the &quot;<i>Default SMTP Virtual Server</i>&quot;, if it is not available, then you need to install it. <li>To configure &quot;<i>Default SMTP Virtual Server</i>&quot;, right-click on it, go into &quot;<i>Properties</i>&quot;, and select &quot;<i>Access</i>&quot; tab, and then click the &quot;<i>Relay</i>&quot; button. With &quot;<i>only the list below</i>&quot; radio button selected, you should see the local IP address: &quot;127.0.0.1&quot;, if it's not there, you need to add it. <li>If you are using &quot;localhost&quot; or &quot;127.0.0.1&quot; as the <code>SmtpMail.SmtpServer</code>, make sure &quot;<i>Anonymous access is allowed</i>&quot;. To allow access, open up the IIS. Locate the SMTP virtual server, and right-click select <i>Properties</i>. On the <i>Access tab</i>, click the <i>Authentication button</i>. Make sure &quot;<i>Anonymous Access</i>&quot; is the only checkbox checked. <li>Use real <b>from</b> and <b>to</b> addresses that exist on the <code>SmtpMail.SmtpServer</code>. Do not use invalid address</li></ol> <p> </p> <p> </p> <p><font size=5>But still i cannot send my mail? So any solution?</font></p> <p> </p> <p>Thanks a lot.</p> <p> </p><font color="#0000ff" size=2> <p>// These are my codes</p> <p>using</font><font size=2> System;</p></font><font color="#0000ff" size=2> <p>using</font><font size=2> System.Data;</p></font><font color="#0000ff" size=2> <p>using</font><font size=2> System.Configuration;</p></font><font color="#0000ff" size=2> <p>using</font><font size=2> System.Collections;</p></font><font color="#0000ff" size=2> <p>using</font><font size=2> System.Web;</p></font><font color="#0000ff" size=2> <p>using</font><font size=2> System.Web.Security;</p></font><font color="#0000ff" size=2> <p>using</font><font size=2> System.Web.UI;</p></font><font color="#0000ff" size=2> <p>using</font><font size=2> System.Web.UI.WebControls;</p></font><font color="#0000ff" size=2> <p>using</font><font size=2> System.Web.UI.WebControls.WebParts;</p></font><font color="#0000ff" size=2> <p>using</font><font size=2> System.Web.UI.HtmlControls;</p></font><font color="#0000ff" size=2> <p>using</font><font size=2> System.Net.Mail;</p></font><font color="#0000ff" size=2> <p>public</font><font size=2> </font><font color="#0000ff" size=2>partial</font><font size=2> </font><font color="#0000ff" size=2>class</font><font size=2> </font><font color="#008080" size=2>mail1</font><font size=2> : System.Web.UI.</font><font color="#008080" size=2>Page</p></font><font size=2> <p>{</p> <p></font><font color="#0000ff" size=2>protected</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> Page_Load(</font><font color="#0000ff" size=2>object</font><font size=2> sender, </font><font color="#008080" size=2>EventArgs</font><font size=2> e)</p> <p>{</p> <p>}</p> <p></font><font color="#0000ff" size=2>protected</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> Button1_Click(</font><font color="#0000ff" size=2>object</font><font size=2> sender, </font><font color="#008080" size=2>EventArgs</font><font size=2> e)</p> <p>{</p> <p></font><font color="#008080" size=2>MailMessage</font><font size=2> objMsg = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>MailMessage</font><font size=2>(TextBox1.Text, TextBox2.Text);</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (TextBox3.Text != </font><font color="#800000" size=2>&quot;&quot;</font><font size=2>)</p> <p>{</p> <p>objMsg.CC.Add(TextBox3.Text);</p> <p>}</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (TextBox4.Text != </font><font color="#800000" size=2>&quot;&quot;</font><font size=2>)</p> <p>{</p> <p>objMsg.Bcc.Add(TextBox4.Text);</p> <p>}</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (TextBox5.Text != </font><font color="#800000" size=2>&quot;&quot;</font><font size=2>)</p> <p>{</p> <p>objMsg.Subject = TextBox5.Text;</p> <p>}</p> <p>objMsg.Body = TextBox6.Text;</p> <p>objMsg.IsBodyHtml = </font><font color="#0000ff" size=2>true</font><font size=2>;</p> <p>objMsg.Priority = </font><font color="#008080" size=2>MailPriority</font><font size=2>.High;</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (TextBox7.Text != </font><font color="#800000" size=2>&quot;&quot;</font><font size=2>)</p> <p>{</p> <p></font><font color="#008080" size=2>Attachment</font><font size=2> objAttc = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>Attachment</font><font size=2>(TextBox7.Text);</p> <p>objMsg.Attachments.Add(objAttc);</p> <p>}</p> <p></font><font color="#008080" size=2>SmtpClient</font><font size=2> objClient = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>SmtpClient</font><font size=2>(</font><font color="#800000" size=2>&quot;localhost&quot;</font><font size=2>,25);</p> <p>objClient.Send(objMsg);</p> <p>Label8.Text = </font><font color="#800000" size=2>&quot;Mail Gönderildi&quot;</font><font size=2>;</p> <p>}</p> <p>}</p></font>Mon, 07 Aug 2006 16:23:24 Z2006-08-07T16:23:24Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3879f7f4-fe85-42c3-b3fa-83cf174fff82http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3879f7f4-fe85-42c3-b3fa-83cf174fff82EthanShttp://social.msdn.microsoft.com/Profile/en-US/?user=EthanSHow do I send mail using C#?<p>I was having a similar problem with my code. My problem was with my virus scan program. Try disabling your virus scan temporarily and running the program; if it works while the virus scan program is disabled, that is the problem. Re-enable it and adjust your settings. I am using McAffee, so here's how you fix it in there:</p> <p>1. Go to the virus scan console (you can get there by right-clicking on the virus scan symbol on the toolbar next to your clock and clicking on &quot;VirusScan Console&quot;).</p> <p>2. Double-click on &quot;Access Protection&quot;</p> <p>3. Find the rule that says &quot;Prevent mass mailing worms from sending mail&quot; and edit it.</p> <p>4. Add your program to the list of &quot;Excluded Processes.&quot;</p> <p>5. Click OK, apply the change, and close the console.</p> <p>This may fix your problem. If not, it is something else, but this is the first thing I would look at. The problem is that virus scan blocks anything outgoing on port 25, which is used for e-mail, and prevents any program not on the &quot;approved list&quot; from sending e-mail. Thus, there is a good chance that your virus scan thinks your program is a worm trying to send out mass mailings against your will.</p> <p> </p> <p>Hope this fixes the problem.</p> <p><br>EthanS</p>Mon, 07 Aug 2006 16:42:41 Z2006-08-07T16:42:41Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#64f82108-3647-4c00-92d7-a12546f5ec69http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#64f82108-3647-4c00-92d7-a12546f5ec69sharn722http://social.msdn.microsoft.com/Profile/en-US/?user=sharn722How do I send mail using C#?<p>hi,</p> <p>i want to use my outlook email address (or any email account setup on the machine...) settings to send mails from my application.</p> <p>specially to set the HOST in the SmtpClient, i want to pick it from the configured mail account.</p> <p>how could that be done.</p> <p>regards,</p> <p>sharn722 </p> <p> </p> <p> </p> <p> </p> <p> </p>Wed, 04 Oct 2006 10:12:43 Z2006-10-04T10:12:43Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#5aaae92d-5671-46b8-b3ef-d478aa280671http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#5aaae92d-5671-46b8-b3ef-d478aa280671Pepepacohttp://social.msdn.microsoft.com/Profile/en-US/?user=PepepacoHow do I send mail using C#?if you already have a configured email account, you may not need to specify anything by code, CDO objects will use by default the current settings.Wed, 04 Oct 2006 13:35:59 Z2006-10-04T13:35:59Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#5b330c96-5ef2-4c0f-bd4e-5f5d4856071dhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#5b330c96-5ef2-4c0f-bd4e-5f5d4856071dPanatulahttp://social.msdn.microsoft.com/Profile/en-US/?user=PanatulaHow do I send mail using C#?<p>Josh I am still struggling with this problem</p> <p>By looking at all the posts you guys have I am assuming you have found a solution and way to debug the problem</p> <p>Could you please help me on this,</p> <p>Thanks for your input.</p> <p>I will really appreciate any help. I am trying to use my gmail account to send me an email to my hotmail account</p> <p> </p> <p>Here is the code sinppet for your reference</p> <p>**********************</p><font color="#008080" size=2> <p>MailMessage</font><font size=2> mailMessage = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>MailMessage</font><font size=2>();</p> <p></font><font color="#0000ff" size=2>try</p></font><font size=2> <p>{</p> <p>EmailResultTextBox.Text = </font><font color="#800000" size=2>&quot;Started @&quot;</font><font size=2> + </font><font color="#008080" size=2>DateTime</font><font size=2>.Now + </font><font color="#008080" size=2>Environment</font><font size=2>.NewLine;</p> <p></font><font color="#008080" size=2>SmtpClient</font><font size=2> client = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>SmtpClient</font><font size=2>(SMPTPServerTextBox.Text.Trim());</p> <p></font><font color="#008000" size=2>// client.Host = SMPTPServerTextBox.Text.Trim();</p></font><font size=2> <p></font><font color="#0000ff" size=2>string</font><font size=2> emailUserName = FromAddressEmailTextBox.Text.Trim();</p> <p></font><font color="#0000ff" size=2>string</font><font size=2> emailPassword = EmailPasswordTextBox.Text.Trim();</p> <p>client.UseDefaultCredentials = </font><font color="#0000ff" size=2>false</font><font size=2>;</p> <p></font><font color="#008000" size=2>//mailClient.UseDefaultCredentials = False</p></font><font size=2> <p>client.Credentials = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>NetworkCredential</font><font size=2>(emailUserName, emailPassword);</p> <p></p> <p>client.EnableSsl = </font><font color="#0000ff" size=2>true</font><font size=2>;</p> <p></font><font color="#0000ff" size=2>string</font><font size=2> toAddress = ToAddressEmailTextBox.Text.Trim();</p> <p>mailMessage.To.Add(</font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>MailAddress</font><font size=2>(toAddress));</p> <p>mailMessage.From = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>MailAddress</font><font size=2>(emailUserName);</p> <p>mailMessage.Subject = SubjectTextBox.Text.Trim();</p> <p>mailMessage.Body = EmailBodyTextBox.Text.Trim();</p> <p></font><font color="#008000" size=2>//Specifying the real SMTP Mail Server.</p></font><font size=2> <p></p> <p>client.DeliveryMethod = </font><font color="#008080" size=2>SmtpDeliveryMethod</font><font size=2>.Network;</p> <p>EmailResultTextBox.Text += </font><font color="#800000" size=2>&quot;Going to call send @&quot;</font><font size=2> + </font><font color="#008080" size=2>DateTime</font><font size=2>.Now + </font><font color="#008080" size=2>Environment</font><font size=2>.NewLine;</p> <p>client.Send(mailMessage);</p> <p>EmailResultTextBox.Text += </font><font color="#800000" size=2>&quot;Successfully sent mail @&quot;</font><font size=2> + </font><font color="#008080" size=2>DateTime</font><font size=2>.Now + </font><font color="#008080" size=2>Environment</font><font size=2>.NewLine;</p> <p></font><font color="#008000" size=2>// Logger.LogInfo(&quot;Successfully Sent Email&quot;);</p></font><font size=2> <p>}</p> <p></font><font color="#0000ff" size=2>catch</font><font size=2> (</font><font color="#008080" size=2>Exception</font><font size=2> ex)</p> <p>{</p> <p>EmailResultTextBox.Text += </font><font color="#800000" size=2>&quot;Failed @&quot;</font><font size=2> + </font><font color="#008080" size=2>DateTime</font><font size=2>.Now + </font><font color="#008080" size=2>Environment</font><font size=2>.NewLine;</p> <p>EmailResultTextBox.Text += ex.Message;</p> <p></p> <p>}</p></font>Tue, 31 Oct 2006 23:32:29 Z2006-10-31T23:32:29Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#8f0f5b93-9cb6-41c7-806e-1158c38bca60http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#8f0f5b93-9cb6-41c7-806e-1158c38bca60blgnklchttp://social.msdn.microsoft.com/Profile/en-US/?user=blgnklcHow do I send mail using C#?<p>hey evreything was  the same,</p> <p>till  i had installed mail enable program.<br>you can get it from : <a title="http://www.mailenable.com/download.asp" href="http://www.mailenable.com/download.asp">http://www.mailenable.com/download.asp</a> then download &gt; Standard Edition, feel free , it is free!</p> <p>ask me if more Question about my problem, my e-mail is <a title="mailto:blgnklc@gmail.com" href="mailto:blgnklc@gmail.com">blgnklc@gmail.com</a></p> <p>Bilgin KILIÇ</p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p>my best forum in turkish: <a title="http://www.damlalar.com" href="http://www.damlalar.com">www.damlalar.com</a><br>just sharing my mood and knowledge</p>Wed, 01 Nov 2006 06:46:48 Z2006-11-01T06:46:48Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#c5cd0605-5a7e-493c-b911-dc57a24c6732http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#c5cd0605-5a7e-493c-b911-dc57a24c6732Roman Rozinovhttp://social.msdn.microsoft.com/Profile/en-US/?user=Roman%20RozinovHow do I send mail using C#?Damn, thanks for the hint.  That's exactly the problem I had. New McAffee features a port blocking engine that prevents outbounds to various known ports including smtp, irc, etc...Wed, 08 Nov 2006 21:03:29 Z2006-11-08T21:03:29Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#7db7100c-c8f7-408e-b354-b6ca64357197http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#7db7100c-c8f7-408e-b354-b6ca64357197parmashttp://social.msdn.microsoft.com/Profile/en-US/?user=parmasHow do I send mail using C#?<P>Hi.</P> <P>I'm trying to send an e-mail from a winform. I want to send it from a hotmail account to any other domain's account. Is this possible?</P> <P>Which SMTP server should I use?</P> <P>I've tried this code.&nbsp;</P><FONT size=2> <P>&nbsp;</P> <P>System.Net.Mail.</FONT><FONT color=#008080 size=2>MailMessage</FONT><FONT size=2> message = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> System.Net.Mail.</FONT><FONT color=#008080 size=2>MailMessage</FONT><FONT size=2>();</P> <P>message.To.Add(</FONT><FONT color=#800000 size=2>"parmas.pb@gmail.com"</FONT><FONT size=2>);</P> <P>message.Subject = </FONT><FONT color=#800000 size=2>"This is the Subject line"</FONT><FONT size=2>;</P> <P>message.From = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> System.Net.Mail.</FONT><FONT color=#008080 size=2>MailAddress</FONT><FONT size=2>(</FONT><FONT color=#800000 size=2>"account@hotmail.com"</FONT><FONT size=2>);</P> <P>message.Body = </FONT><FONT color=#800000 size=2>"This is the message's body."</FONT><FONT size=2>;</P> <P>System.Net.Mail.</FONT><FONT color=#008080 size=2>SmtpClient</FONT><FONT size=2> smtp = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> System.Net.Mail.</FONT><FONT color=#008080 size=2>SmtpClient</FONT><FONT size=2>(</FONT><FONT color=#800000 size=2>"mail.hotmail.com"</FONT><FONT size=2>);</P> <P>smtp.Credentials = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> System.Net.</FONT><FONT color=#008080 size=2>NetworkCredential</FONT><FONT size=2>(</FONT><FONT color=#800000 size=2>"account"</FONT><FONT size=2>, </FONT><FONT color=#800000 size=2>"password"</FONT><FONT size=2>);</P> <P>smtp.Send(message);</P></FONT> <P>&nbsp;</P> <P>I don't get any compiling errors but&nbsp;the sending-mail operation its timed out.</P> <P>If anyone knows how to make this work out I will be really thankful.</P> <P>&nbsp;</P> <P>Greetings &amp; Happy New Year 2007.</P> <P>&nbsp;</P> <P>&nbsp;</P> <P>&nbsp;</P>Wed, 03 Jan 2007 19:37:33 Z2007-01-03T19:37:33Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ed94dd02-5d33-4e57-8000-64afcc515a7ehttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ed94dd02-5d33-4e57-8000-64afcc515a7eashish12345http://social.msdn.microsoft.com/Profile/en-US/?user=ashish12345How do I send mail using C#?<p>Hi All,</p> <p>  I need your help regarding sending Email through Microsoft Exchange Server. Is there any code snippet or any .dll which will give me the brief idea?</p> <p>      As per my info Exchange server act as wrapper and invokes SMTP internally to send the mail. Outlook is client and been connected to exchange server. I don't want to install outlook on my machine and want to directly connect to exchange server which is located at company network.</p> <p>C# code/snippet preferable</p> <p>Could you Pls help me in doing this....</p> <p> </p> <p>Thanks,</p> <p>Ashish</p> <p> </p> <p> </p>Wed, 24 Jan 2007 06:13:35 Z2007-01-24T06:13:35Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#29333d69-9021-423c-bc92-3e56e174134bhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#29333d69-9021-423c-bc92-3e56e174134bPepepacohttp://social.msdn.microsoft.com/Profile/en-US/?user=PepepacoHow do I send mail using C#?<p>simply use your exchange server as SMTP log in using the email account credentials and use any of the snnipets in this page.</p> <p> </p>Wed, 24 Jan 2007 14:12:44 Z2007-01-24T14:12:44Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3df0cabc-db5f-4857-99c6-6091c9f3e019http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3df0cabc-db5f-4857-99c6-6091c9f3e019ashish12345http://social.msdn.microsoft.com/Profile/en-US/?user=ashish12345How do I send mail using C#?Thanks a lot , it works <img src="/MSDN//emoticons/emotion-1.gif" alt=Smile>Thu, 25 Jan 2007 09:19:49 Z2007-01-25T09:19:49Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#9beecbb2-d811-4948-8d63-0422f8c9cf64http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#9beecbb2-d811-4948-8d63-0422f8c9cf64anjalisharmahttp://social.msdn.microsoft.com/Profile/en-US/?user=anjalisharmaHow do I send mail using C#?I want to do the same job but I want to send attachments as well. Please help. Thanks in advanceTue, 20 Mar 2007 08:57:02 Z2007-03-20T08:57:02Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#50f6ae7e-bb31-4bbb-8a1e-bd81d1fe381dhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#50f6ae7e-bb31-4bbb-8a1e-bd81d1fe381dybao2000http://social.msdn.microsoft.com/Profile/en-US/?user=ybao2000How do I send mail using C#?Gmail works fine, but I could NEVER make hotmail and yahoo work. What is hotmail/yahoo's smtp server name? Or they just don't support it?Thu, 22 Mar 2007 21:05:18 Z2007-03-22T21:05:18Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#d2301f0c-722e-4ea6-9700-b59d4b035503http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#d2301f0c-722e-4ea6-9700-b59d4b035503ybao2000http://social.msdn.microsoft.com/Profile/en-US/?user=ybao2000How do I send mail using C#?Plese tell me how to make hotmail or yahoo work. Or, what's their smtp server name?Thu, 22 Mar 2007 21:08:50 Z2007-03-22T21:08:50Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#a1dff9e7-a1ef-4957-9508-5c1b0f69dc54http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#a1dff9e7-a1ef-4957-9508-5c1b0f69dc54BVG1http://social.msdn.microsoft.com/Profile/en-US/?user=BVG1How do I send mail using C#?Nice example.<br>But, how can I send embedded images in the e-mail, using <span><span class=txt4 id="_ctl0_MainContent__ctl0_PostForm_ReplyBody">the Exchange Server mailbox over http using WebDAV?</span></span><br><br>Many thanks <img height=19 alt=Smile src="http://forums.microsoft.com/MSDN/emoticons/emotion-1.gif" width=19><br>Thu, 05 Apr 2007 12:41:29 Z2007-04-05T12:41:29Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#6f29414d-7dd8-48f1-bbb8-1e297b8d22f9http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#6f29414d-7dd8-48f1-bbb8-1e297b8d22f9Rizvanhttp://social.msdn.microsoft.com/Profile/en-US/?user=RizvanHow do I send mail using C#?I have five text box , I want to send textbox value send by mail to particular email Address,How can I send value of text box directly by mailIn VS2005 using C#Tue, 05 Jun 2007 06:58:05 Z2007-06-05T06:58:05Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ef87a8c2-0a2e-4ac2-9ca8-6af323e56969http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ef87a8c2-0a2e-4ac2-9ca8-6af323e56969hajaworldhttp://social.msdn.microsoft.com/Profile/en-US/?user=hajaworldHow do I send mail using C#?I have try  the following code snippet<br>help where is the proble,i have received an error <br><span style="font-weight:bold">unavailable textbox,cant reley the mail to this id</span><br><br>i have specified localhost as the smtp mail server,is any other name?<br><br><br>&lt;%@ Import Namespace=&quot;System.Web.Mail&quot; %&gt;<br><br>&lt;html&gt;<br><br>&lt;script language=&quot;VB&quot; runat=&quot;server&quot;&gt;<br>Sub Page_Load(Sender As Object, E As EventArgs)<br><br>     Dim msg as New MailMessage()<br><br>     msg.To = &quot;hajaworld@gmail.com&quot;<br>     msg.From = &quot;hajaworld@gmail.com&quot;<br>     msg.Subject = &quot;test&quot;<br>     'msg.BodyFormat = MailFormat.Html<br>     msg.BodyFormat = MailFormat.Text<br>     msg.Body = &quot;hi&quot;<br><br>     SmtpMail.SmtpServer = &quot;localhost&quot;<br><br>     SmtpMail.Send(msg)<br>     msg = Nothing<br>     lblMsg.Text = &quot;An Email has been send to &quot; &amp; &quot;hajaworld@gmail.com&quot;<br><br>End Sub<br>&lt;/script&gt;<br><br>&lt;body style=&quot;font: 10pt verdana&quot;&gt;<br>&lt;form runat=&quot;server&quot;&gt;<br>&lt;asp:Label id=lblMsg runat=&quot;Server&quot; /&gt; &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>Mon, 02 Jul 2007 06:51:47 Z2007-07-02T06:51:47Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#4bf167c5-dbde-4a36-95fd-56d4c0e10664http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#4bf167c5-dbde-4a36-95fd-56d4c0e10664Jeevansdhttp://social.msdn.microsoft.com/Profile/en-US/?user=JeevansdHow do I send mail using C#?Hi josh I tried to send mail using code but I am getting error .Fields does not exist, although I am using VS2005 C# and I have added ref of CDO from library.<br>Please give me suggestion.<br>Thanks in advance for showing the way.<br>Regards,<br>Jeevan<br>Wed, 18 Jul 2007 12:04:51 Z2007-07-18T12:04:51Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#85d62ca7-d533-4e73-be9d-6eed6c93f8f1http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#85d62ca7-d533-4e73-be9d-6eed6c93f8f1saiswahttp://social.msdn.microsoft.com/Profile/en-US/?user=saiswaHow do I send mail using C#?Were you able to get this working with basic authentication with IIS 6?<br>Thu, 19 Jul 2007 21:01:57 Z2007-07-19T21:01:57Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#b153c7cc-ef44-43e9-98f4-d5f45d0e9823http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#b153c7cc-ef44-43e9-98f4-d5f45d0e9823Jeevansdhttp://social.msdn.microsoft.com/Profile/en-US/?user=JeevansdHow do I send mail using C#?I have used form authentication in my web application. and I am using VS 2005 with C#.<br>This is the code i have written.It is not giving any exception. but still the mail is not going.<br><br>try<br>        {<br>            //creating new mail.<br>            System.Net.Mail.MailMessage newmail = new System.Net.Mail.MailMessage();<br><br>            //setting mail parameters<br>            newmail.To.Add(&quot;sendme@gmail.com&quot;);<br>            newmail.From = new System.Net.Mail.MailAddress(&quot;xyz.abc@gmail.com&quot;, &quot;XYZ&quot;, System.Text.Encoding.UTF8);<br>            newmail.Subject = &quot;Lost id or password&quot;;<br><br>            <br>            //writing mail body<br>            String mailbodytext = &quot;This is a auto generated mail.&quot;;<br>            <br>            newmail.Body = mailbodytext;<br><br>            <br>            //sending the mail.<br><br>            System.Net.Mail.SmtpClient theClient = new System.Net.Mail.SmtpClient();<br>            System.Net.NetworkCredential theCredential = new                System.Net.NetworkCredential(&quot;abcdef@gmail.com&quot;, &quot;abcabc&quot;);<br>            theClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;<br>            <br>            theClient.Port = 465;<br>            theClient.Host=&quot;smtp.gmail.com&quot;;<br>            theClient.EnableSsl = true;<br>            theClient.UseDefaultCredentials = false;<br>            <br>            theClient.Credentials = theCredential;<br>            <br>            object userstate = newmail;<br>            <br>            theClient.SendAsync(newmail,userstate);<br>            //theClient.Send(newmail);<br>            <br>            <br>        }<br>        catch (System.Net.Mail.SmtpException smex)<br>        {<br>            Console.Write(smex.Message,&quot;Send Mail Error&quot;);<br>        }<br>        catch (System.Exception ex)<br>        {<br>           Console.Write(ex.Message);<br>        }<br>Fri, 20 Jul 2007 05:55:30 Z2007-07-20T05:55:30Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#fc6d9c2e-5c09-4680-a354-b3ecdbfea19ahttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#fc6d9c2e-5c09-4680-a354-b3ecdbfea19asaiswahttp://social.msdn.microsoft.com/Profile/en-US/?user=saiswaHow do I send mail using C#?I'm having a similar issue. I believe that this is a bug in the .NET framework.<br>The deprecated CDONT example works fine, however.<br>Fri, 20 Jul 2007 23:14:02 Z2007-07-20T23:14:02Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#80662b57-59d4-4ea2-84eb-b76a1442b18bhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#80662b57-59d4-4ea2-84eb-b76a1442b18blildiapazhttp://social.msdn.microsoft.com/Profile/en-US/?user=lildiapazHow do I send mail using C#?Hello,<br><br>I tried your code and it didn't work, It compiled fine, but it gave me a message that it couldn't connect to the server and the code broke at this line <span><span class=txt4 id="_ctl0_MainContent__ctl0_PostForm_ReplyBody"><font size=2>System.Web.Mail.SmtpMail.Send(message); What can be the problem? I'm just trying to send an email in a c# windows form. do I have to modify something in code?, Sorry if this is easy, but I'm new to .NET<br><br>this what I had:<br>System.Web.Mail.MailMessage message = new System.Web.Mail.MailMessage();<br><br>            message.Fields.Add(&quot;http://schemas.microsoft.com/cdo/configuration/smtpauthenticate&quot;, 1);<br>            message.Fields.Add(&quot;http://schemas.microsoft.com/cdo/configuration/sendusername&quot;, &quot;SmtpHostUserName&quot;);<br>            message.Fields.Add(&quot;http://schemas.microsoft.com/cdo/configuration/sendpassword&quot;, &quot;SmtpHostPassword&quot;);<br><br>            message.From = &quot;from e-mail&quot;;<br>            message.To = &quot;to e-mail&quot;;<br>            message.Subject = &quot;Message Subject&quot;;<br>            message.Body = &quot;Message Body&quot;;<br><br>            System.Web.Mail.SmtpMail.SmtpServer = &quot;SMTP Server Address&quot;;<br>            System.Web.Mail.SmtpMail.Send(message);<br></font></span></span>Wed, 01 Aug 2007 18:55:41 Z2007-08-01T18:55:41Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#99a04cf0-10b4-4f6f-b6c5-b247a2ccf637http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#99a04cf0-10b4-4f6f-b6c5-b247a2ccf637Pepepacohttp://social.msdn.microsoft.com/Profile/en-US/?user=PepepacoHow do I send mail using C#?<p align=left><font face=Arial size=2></font> </p> <p>please try the code i put at page 2, if doenst work either check for the antivirus software is not blocking ur app to send the email, and check if the firewall is not blocking port 25.</p> <p align=left> </p> <p align=left> </p>Wed, 01 Aug 2007 21:29:07 Z2007-08-01T21:29:07Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#237d5512-8677-498d-ae43-f6235bcfc919http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#237d5512-8677-498d-ae43-f6235bcfc919Anonymous234556http://social.msdn.microsoft.com/Profile/en-US/?user=Anonymous234556How do I send mail using C#?<p align=left><font face=Arial size=2>Hi,</font></p> <p align=left> </p> <p align=left>i want to send the MailMessage Object via HTTP (Webrequest). This is neccesary for a S/MIME communication over HTTP (AS2).</p> <p align=left> </p> <p align=left>I get a positive response (MDN) but the target File simple contains &quot;System.Net.Mail.MailMessage&quot;. Since the Message is a multipart Message with signatur and is crypted i can not create a simple String-Email as shown earlyer in this Thread.</p> <p align=left> </p> <p align=left>I use following code:</p> <p align=left> </p> <p align=left>            MailMessage Msg = new MailMessage();<br><br>            Msg.From = new MailAddress(&quot;<a href="mailto:email@provider.de">email@provider.de</a>&quot;);<br>            Msg.To.Add(&quot;<a href="mailto:email@provider.de"> email@provider.de</a>&quot;);<br>            Msg.Subject = &quot;Betreff&quot;;<br><br>            Uri uri = new Uri(&quot;<a href="http://127.0.0.1:port/">http://127.0.0.1<img alt="Stick out tongue" src="http://forums.microsoft.com/MSDN/emoticons/emotion-4.gif">ort/</a>&quot;);<br>            WebRequest wReq = WebRequest.Create(uri);<br>            wReq.Method = &quot;PUT&quot;;<br><br>            StreamWriter sw = new StreamWriter(wReq.GetRequestStream());<br>            sw.Write(Msg);</p> <p align=left> </p> <p align=left>here i want to send the hole MailMassege but get only &quot;System.Net.Mail.MailMessage&quot;</p> <p align=left><br>            sw.Close();<br>            WebResponse wResp = wReq.GetResponse();<br>            StreamReader sr = new StreamReader(wResp.GetResponseStream());<br>            String response = sr.ReadToEnd();<br>            sr.Close();</p> <p> </p> <p align=left>Any sugestions?</p> <p align=left> </p>Thu, 23 Aug 2007 18:26:01 Z2007-08-23T18:26:01Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#e77a9ed4-36fc-4f3e-be8c-0fc0cb60a9d9http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#e77a9ed4-36fc-4f3e-be8c-0fc0cb60a9d9CodeSrihttp://social.msdn.microsoft.com/Profile/en-US/?user=CodeSriHow do I send mail using C#?hi...<br><br>could you tell me how to find my smtphost.??<br><br>i changed ur code to this ... added whatever i needed..<br> private void button1_Click(object sender, EventArgs e)<br>        {<br>               System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();<br>                message.To.Add(&quot;sreeks_13@yahoo.co.in&quot;);<br>                message.Subject = &quot;This is the Subject line&quot;;<br>                message.From = new System.Net.Mail.MailAddress(&quot;sreeks13@gmail.com&quot;);<br>                message.Body = &quot;This is the message body&quot;;<br>                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(&quot;smtp.yahoo.com&quot;);<br>                smtp.Send(message);<br>            }<br><br>but i dont know for some reason doesnt work ..<br>i wonder if i am using the correct smtp client i am not sure what exactly to do there.<br>Fri, 23 Nov 2007 09:16:51 Z2007-11-23T09:16:51Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#6d2be959-2606-48d8-a5db-deb5582b1caahttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#6d2be959-2606-48d8-a5db-deb5582b1caaPepepacohttp://social.msdn.microsoft.com/Profile/en-US/?user=PepepacoHow do I send mail using C#?<p align=left><font face=Arial size=2></font> </p> <p>Bad news, if u didnt pay for yahoo smpt you are not going to be able to use their smtp, better to find another free one, like gmail i belive there are some examples on previous posts...</p> <p align=left> </p> <p align=left>thanks.</p> <p align=left> </p>Fri, 23 Nov 2007 23:25:18 Z2007-11-23T23:25:18Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#8569e178-db17-4a4a-afd2-ddfad5aadbf5http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#8569e178-db17-4a4a-afd2-ddfad5aadbf5Vimal Tiwarihttp://social.msdn.microsoft.com/Profile/en-US/?user=Vimal%20TiwariHow do I send mail using C#?<p align=left><font face=Verdana>i m trying to send mail using win application, i m able to send mail using gmail smtp but not able to send using any of the yahoo, rediff, hotmail or anyother smtp server. On using any of these server I am getting smtp exception(The SMTP server requires a secure connection or the client was not authenticated).Is this doing some extra setting for sending the mail using these ? if yes plz tell me or they are paid smtp server? Is this possible to get that which one is paid smtp server.If yes, please tell, how?</font></p> <p align=left><font face=Verdana>Thanks,</font></p>Sat, 24 Nov 2007 15:35:01 Z2007-11-24T15:35:01Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#2682bb30-3dda-4161-8ce5-759bc2e7adf2http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#2682bb30-3dda-4161-8ce5-759bc2e7adf2ali abdulhttp://social.msdn.microsoft.com/Profile/en-US/?user=ali%20abdulHow do I send mail using C#?<p align=left><font face=Arial size=2>helloo...</font></p> <p align=left>i find same code about send mail using C# , but it dosn't work</p> <p align=left>so can you tell me if i useing VBasic code or ASP.net code how do i do that ( send the mail ) I try many way but not work.</p> <p align=left> </p>Sun, 16 Dec 2007 22:34:43 Z2007-12-16T22:34:43Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#10087079-38a7-4b4c-bd85-64837b5e7e60http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#10087079-38a7-4b4c-bd85-64837b5e7e60DranaXumhttp://social.msdn.microsoft.com/Profile/en-US/?user=DranaXumHow do I send mail using C#?I read some posts and it seems many of us have problems with getting that Smtp server working. I came up with a working sollution to your problems but you will have to use local smtp server.<br><br>You have to install IIS (which some of you already have installed because of Visual Studio), and after this go to Administrative tools, IIS and setup the Virtual Smtp Server to grant permission to localhost.<br><br>After this you can test it:<br>(example in C# .NET 2.0)<br><br> <div style="text-align:left"> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Block<br></span></div> <p>SmtpClient g = new SmtpClient();<br>g.Host = &quot;localhost&quot;;<br>g.Send(&quot;from@host.com&quot;, &quot;recepient@host.com&quot;, &quot;testsubject&quot;, &quot;message&quot;);</p> <p></p></div></div><br></div>Hope this solves your problems!<br><br><br>PS: For the &quot;from&quot; parameter you can use any email address you like.<br>PPS: If you send to a yahoo address, please check the spam folder <img height=19 alt=Smile src="http://forums.microsoft.com/MSDN/emoticons/emotion-1.gif" width=19><br>Tue, 01 Jan 2008 14:55:19 Z2008-01-01T14:55:19Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#86d9d336-74ae-472e-b4de-e67b21e6ea78http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#86d9d336-74ae-472e-b4de-e67b21e6ea78Nikunj Ganatrahttp://social.msdn.microsoft.com/Profile/en-US/?user=Nikunj%20GanatraHow do I send mail using C#?<br>I have try ur code...like this<br>            <br>            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();<br>            message.To.Add(&quot;nikunjganatra007@gmail.com&quot;);<br>            message.Subject = &quot;This is the Subject line&quot;;<br>            message.From = new System.Net.Mail.MailAddress(&quot;projecttest@proseon.com&quot;);<br>            message.Body = &quot;This is the message body&quot;;<br>            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(&quot;127.0.0.1&quot;,25);<br>            smtp.Send(message);<br><br><br>here nikunjganatra007@gmail.com is my personal id, and projecttest@proseon.com is my compnay's id.<br>is there any SMTP settings/configuration require....<br><br>it throws exeception like this:<br><br><span id=Label1 style="left:160px;position:relative;top:-6px">System.Net.Mail.SmtpException: Failure sending mail. ---&gt; System.Net.WebException: Unable to connect to the remote server ---&gt; System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket&amp; socket, IPAddress&amp; address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception&amp; exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress&amp; address, Socket&amp; abortSocket, Socket&amp; abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at _Default.Button2_Click(Object sender, EventArgs e) in c:\WebSites\WebSite1\Default.aspx.cs:line 109</span> <br>Mon, 11 Feb 2008 07:10:31 Z2008-02-11T07:10:31Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#bd8c4731-232b-41a7-8d81-4adede5cb489http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#bd8c4731-232b-41a7-8d81-4adede5cb489Nikunj Ganatrahttp://social.msdn.microsoft.com/Profile/en-US/?user=Nikunj%20GanatraHow do I send mail using C#?<br>hi, I m also getting same problem in sending mail...<br><br>if u have found solution then plz send me on nikunjganatra2003@gmail.com<br>thanks.<br>Mon, 11 Feb 2008 07:20:57 Z2008-02-11T07:20:57Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#7507f863-f2bb-4682-9ca6-f765bf719af1http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#7507f863-f2bb-4682-9ca6-f765bf719af1Skalichttp://social.msdn.microsoft.com/Profile/en-US/?user=SkalicHow do I send mail using C#?Dear Mohamed, <br>I am running MONO.NET on my Linux server. I was just wondering if you could give me an advice about sending mail from MONO. The compilation is without problems, but after there is Error message 500:<br>I have tried this several options see bellow:<br>http://tadmin.eutree.eu/Pavel/Email5/<br>http://tadmin.eutree.eu/Pavel/Email8/  (your code)<br>and there is still the same problem Error 500 :-(<br>Thanks for anz help<br>Pavel<br>---------------------------------<br> <h2><em>No such host is known</em></h2> <p><strong>Description: </strong>Error processing request.</p> <p><strong>Error Message: </strong>HTTP 500. System.Net.Sockets.SocketException: No such host is known </p> <p><strong>Stack Trace: </strong></p><pre>System.Net.Sockets.SocketException: No such host is known<br> at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] <br> at System.Net.Sockets.TcpClient.Connect (System.String hostname, Int32 port) [0x00000] <br> at System.Net.Sockets.TcpClient..ctor (System.String hostname, Int32 port) [0x00000] <br> at System.Web.Mail.SmtpClient.Connect () [0x00000] <br> at System.Web.Mail.SmtpClient.StartSend (System.Web.Mail.MailMessageWrapper msg) [0x00000] <br> at System.Web.Mail.SmtpClient.Send (System.Web.Mail.MailMessageWrapper msg) [0x00000] <br> at System.Web.Mail.SmtpMail.Send (System.Web.Mail.MailMessage message) [0x00000] <br>----------------<br><br></pre><br>Sun, 04 May 2008 14:53:27 Z2008-05-04T14:53:27Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#4ad6e0c4-d628-4a42-b6e1-715b5e111956http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#4ad6e0c4-d628-4a42-b6e1-715b5e111956ahmedilyashttp://social.msdn.microsoft.com/Profile/en-US/?user=ahmedilyasHow do I send mail using C#?<p align=left><font face=Arial size=2></font> </p> <p>ok lets get this clear</p> <p align=left> </p> <p align=left>1) Not all service providers (email) will allow you to use their SMTP services unless you pay for it, or are allowed to send email via their services for obvious reasons (security, spam prevention etc... etc..)</p> <p align=left>2) There are some free email providers that allow you to use their SMTP as long as you have an email address with them, such as gmail and other providers</p> <p align=left>3) Settings differ from providers, some use SSL like google and on a different port, but commonly and across all SMTP providers, you MUST provide credentials (your email address on that account and password) so they can authenticate you successfully</p> <p align=left>4) Whilst you could set up your own POP3 services on your own computer, you still need to configure it to use relay's, domain's/forwarding etc... etc...</p>Sun, 04 May 2008 21:54:09 Z2008-05-04T21:54:09Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3994d9aa-05e2-476d-b075-6fd69a141082http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3994d9aa-05e2-476d-b075-6fd69a141082Pranaybsinghhttp://social.msdn.microsoft.com/Profile/en-US/?user=PranaybsinghHow do I send mail using C#?  Hi,<br> <p>This is the code in webdav to send mail using exchange server<br><br>public void Sendmail()<br>{<br>        System.Net.HttpWebRequest PUTRequest;<br>        System.Net.HttpWebRequest PUTRequest1;<br>        System.Net.WebResponse PUTResponse;<br>        System.Net.WebResponse PUTResponse1;<br>        System.Net.HttpWebRequest PROPPATCHRequest;<br>        System.Net.WebResponse PROPPATCHResponse;<br>        System.Net.HttpWebRequest MOVERequest;<br>        System.Net.WebResponse MOVEResponse;<br>        System.Net.CredentialCache MyCredentialCache;<br>        string strMailboxURI = &quot;<a href="http://Your">http://Your</a> exchange server/exchange/&quot;;<br>        string strSubURI = &quot;<a href="http://Your">http://Your</a> exchange server/exchange/&quot;;<br>        string strTempURI = &quot;<a href="http://Your">http://Your</a> exchange server/exchange/&quot;;<br>        string strServer = &quot;Your exchange server&quot;;<br>        string strPassword = &quot;your password&quot;;<br>        string strDomain = &quot;your domain&quot;;<br>        string strAlias = &quot;your user name&quot;;<br>        string strTo = &quot;to whom u want to send&quot;;<br>        string strSubject = &quot;Test&quot;;<br>        string strText = &quot;This message was sent using WebDAV&quot;;<br>        string strBody = &quot;&quot;;<br>        byte[] bytes = null;<br>    <br>        System.IO.Stream PUTRequestStream = null;<br>                    <br>            try<br>            {<br>                // Build the mailbox URI.</p> <p>                strMailboxURI = &quot;http://&quot; + strServer + &quot;/exchange/&quot; + strAlias;<br>               <br>                // Build the submission URI for the message. If Secure<br>                // Sockets Layer (SSL) is set up on the server, use<br>                // &quot;https://&quot; instead of &quot;http://&quot;.</p> <p>                strSubURI = &quot;http://&quot; + strServer + &quot;/exchange/&quot; + strAlias +<br>                           &quot;/##DavMailSubmissionURI##/&quot;;<br>                // Build the temporary URI for the message. If SSL is set<br>                // up on the server, use &quot;https://&quot; instead of &quot;http://&quot;.<br>                strTempURI = &quot;http://&quot; + strServer + &quot;/exchange/&quot; + strAlias + &quot;/drafts/&quot; +<br>                               strSubject + &quot;.eml/&quot;;<br>                             <br>                // Construct the RFC 822 formatted body of the PUT request.<br>                // Note: If the From: header is included here,<br>                // the MOVE method request will return a<br>                // 403 (Forbidden) status. The From address will<br>                // be generated by the Exchange server.<br>                strBody = &quot;To: &quot; + strTo + &quot;\n&quot; +<br>     &quot;Subject: &quot; + strSubject + &quot;\n&quot; +<br>     &quot;Date: &quot; + System.DateTime.Now +<br>     &quot;X-Mailer: test mailer&quot; + &quot;\n&quot; +<br>     &quot;MIME-Version: 1.0&quot; + &quot;\n&quot; +<br>     &quot;Content-Type: text/plain;&quot; + &quot;\n&quot; +<br>     &quot;Charset = \&quot;iso-8859-1\&quot;&quot; + &quot;\n&quot; +<br>     &quot;Content-Transfer-Encoding: 7bit&quot; + &quot;\n&quot; +<br>     &quot;\n&quot; + strText;<br>                // Create a new CredentialCache object and fill it with the network<br>                // credentials required to access the server.<br>                MyCredentialCache = new System.Net.CredentialCache();<br>                MyCredentialCache.Add(new System.Uri(strMailboxURI),<br>                &quot;Basic&quot;,<br>                new System.Net.NetworkCredential(strAlias, strPassword, strDomain)<br>                );</p> <p><br>                // Create the HttpWebRequest object.<br>                PUTRequest = (System.Net.HttpWebRequest)HttpWebRequest.Create(strTempURI);<br>                // Add the network credentials to the request.<br>                PUTRequest.Credentials = MyCredentialCache;<br>                // Specify the PUT method.<br>                PUTRequest.Method = &quot;PUT&quot;;<br>                // Encode the body using UTF-8.<br>                bytes = Encoding.UTF8.GetBytes((string)strBody);<br>                // Set the content header length. This must be<br>                // done before writing data to the request stream.<br>                PUTRequest.ContentLength = bytes.Length;<br>                // Get a reference to the request stream.<br>                PUTRequestStream = PUTRequest.GetRequestStream();<br>                // Write the message body to the request stream.<br>                PUTRequestStream.Write(bytes, 0, bytes.Length);<br>                // Close the Stream object to release the connection<br>                // for further use.<br>                PUTRequestStream.Close();<br>                // Set the Content-Type header to the RFC 822 message format.<br>                PUTRequest.ContentType = &quot;message/rfc822&quot;;<br>                // PUT the message in the Drafts folder of the<br>                // sender's mailbox.<br>                PUTResponse = (System.Net.HttpWebResponse)PUTRequest.GetResponse();<br>                // Create the HttpWebRequest object.<br>                MOVERequest = (System.Net.HttpWebRequest)HttpWebRequest.Create(strTempURI);<br>                // Add the network credentials to the request.<br>                MOVERequest.Credentials = MyCredentialCache;<br>                // Specify the MOVE method.<br>                MOVERequest.Method = &quot;MOVE&quot;;<br>                // Set the Destination header to the<br>                // mail submission URI.<br>                MOVERequest.Headers.Add(&quot;Destination&quot;, strSubURI);<br>                // Send the message by moving it from the Drafts folder of the<br>                // sender's mailbox to the mail submission URI.<br>                MOVEResponse = (System.Net.HttpWebResponse)MOVERequest.GetResponse();<br>                Console.WriteLine(&quot;Message successfully sent.&quot;);<br>                // Clean up.<br>                PUTResponse.Close();<br>                MOVEResponse.Close();<br>            }<br>            catch (Exception ex)<br>            {<br>                // Catch any exceptions. Any error codes from the PUT<br>                // or MOVE method requests on the server will be caught<br>                // here, also.<br>                Console.WriteLine(ex.Message);<br>            }<br>        }</p> <hr align=left width="25%" size=1> PranayaTue, 07 Oct 2008 10:00:27 Z2008-10-07T10:03:05Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#d1648ef0-c72c-4825-97df-edce8760c751http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#d1648ef0-c72c-4825-97df-edce8760c751andr62http://social.msdn.microsoft.com/Profile/en-US/?user=andr62How do I send mail using C#?This code is correct. Thanks a lot! Tue, 25 Nov 2008 15:16:27 Z2008-11-25T15:16:27Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ac1272e9-cb8a-4163-b261-23e778992893http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ac1272e9-cb8a-4163-b261-23e778992893sameden2http://social.msdn.microsoft.com/Profile/en-US/?user=sameden2How do I send mail using C#?i have used the code above and it works (i think)<br><br>wht wood i have to change to send lots of emails relly fast  (eg. if i was spaming someone)<br><br>sam eden<br> <hr class="sig">try SAIO v1.0 beta go to sites.google.com/site/sameden2Tue, 03 Mar 2009 19:10:58 Z2009-03-03T19:10:58Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3882d41a-ae0a-496a-b4e4-9fe055508eb4http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3882d41a-ae0a-496a-b4e4-9fe055508eb4ahmedilyashttp://social.msdn.microsoft.com/Profile/en-US/?user=ahmedilyasHow do I send mail using C#? spamming is not good at all and such discussions would not be allowed at all. but to send bulkemails totally depends on the network speed and how fast your system is - nothing else.<hr class="sig">Need 2 be back @ MS - MS All the way! Follower since 1995 MS Super Evangelist| MSDN Forums ModeratorTue, 03 Mar 2009 19:18:16 Z2009-03-03T19:18:16Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ff1a63fe-24f5-4b81-a364-662742cfafa0http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#ff1a63fe-24f5-4b81-a364-662742cfafa0sameden2http://social.msdn.microsoft.com/Profile/en-US/?user=sameden2How do I send mail using C#?i now i was useing it as an example i need it for sending out lots of emails t 1 email adresss <hr class="sig">try SAIO v1.0 beta go to sites.google.com/site/sameden2Tue, 03 Mar 2009 19:35:53 Z2009-03-03T19:35:53Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#fd73d660-e714-4fa8-9dec-2271e01185e1http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#fd73d660-e714-4fa8-9dec-2271e01185e1Serhat SEKERCIhttp://social.msdn.microsoft.com/Profile/en-US/?user=Serhat%20SEKERCIHow do I send mail using C#?ThanksFri, 17 Apr 2009 17:58:03 Z2009-04-17T17:58:03Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#4713cecd-3ce8-4fb2-bae1-f6b68553fe20http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#4713cecd-3ce8-4fb2-bae1-f6b68553fe20Giggig guyhttp://social.msdn.microsoft.com/Profile/en-US/?user=Giggig%20guyHow do I send mail using C#?What if the SMTP server requires authentication?<hr class="sig">Giggig Enterprises http://www.giggig.co.uk/Sat, 06 Jun 2009 21:45:48 Z2009-06-06T21:45:48Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#fe236cad-9514-4252-ad48-263d3d780832http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#fe236cad-9514-4252-ad48-263d3d780832Laddiehttp://social.msdn.microsoft.com/Profile/en-US/?user=LaddieHow do I send mail using C#?Hope this helps<br/><br/><a href="http://www.sourcecodebase.com/Articles/TextArticle.aspx?acid=7">Sending Mail using C#</a>Mon, 08 Jun 2009 06:04:20 Z2009-06-08T06:04:20Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#96274b7e-aa08-4f2c-ad03-0d5be36c3e56http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#96274b7e-aa08-4f2c-ad03-0d5be36c3e56liam_webhttp://social.msdn.microsoft.com/Profile/en-US/?user=liam_webHow do I send mail using C#?check this one<br/><br/><a href="http://csharp.net-informations.com/communications/csharp-smtp-mail.htm">http://csharp.net-informations.com/communications/csharp-smtp-mail.htm</a><br/><br/>liam.Wed, 17 Jun 2009 04:48:36 Z2009-06-17T04:48:36Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#2042aadb-eea0-49b1-8fac-be9d136f8caehttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#2042aadb-eea0-49b1-8fac-be9d136f8caeAnand K Reddyhttp://social.msdn.microsoft.com/Profile/en-US/?user=Anand%20K%20ReddyHow do I send mail using C#?<pre lang="x-c#">I am posting this because though there is lot much discussed, I couldn't see the code snippet for sending emails through exchange server or <br/>https:// servers. <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>SmtpClient smtp = new SmtpClient(); smtp.Port = 25; // specify the smtp port smtp.Host = &quot;Just your host name, no need of preceding with smtp. ect&quot;; // specify the name/ip address of the host smtp.Credentials = new NetworkCredential(usr, passwd); // authenticate // message MailMessage email_msg = new MailMessage(); email_msg.To.Add(&quot;abc@domain.com&quot;); email_msg.From = new MailAddress(&quot;xyz@some.com&quot;); email_msg.Subject = &quot;test mail...&quot;; email_msg.Body = &quot;Hello world!!!&quot;; email_msg.IsBodyHtml = false; smtp.Send(email_msg); // now send the message </pre> <p>Only thing that one should remember not to set <span style="font-size:x-small;color:#008000"><span style="font-size:x-small;color:#008000">EnableSsl = true;. <br/><br/></span></span></p><hr class="sig">AnandFri, 19 Jun 2009 05:00:29 Z2009-06-19T05:00:29Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#14ba7ce9-e0cc-4330-8f32-a4545e403d3bhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#14ba7ce9-e0cc-4330-8f32-a4545e403d3bPeter Harnish1http://social.msdn.microsoft.com/Profile/en-US/?user=Peter%20Harnish1How do I send mail using C#?Is it possible to programatically bring up the default email program on a computer and automatically populate the To, Message, Subject, and Attachment fields?<hr class="sig">Peter HarnishWed, 05 Aug 2009 17:48:01 Z2009-08-05T17:48:01Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3b77c696-0058-4def-b0fa-0a502f74821ehttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#3b77c696-0058-4def-b0fa-0a502f74821emyrocodehttp://social.msdn.microsoft.com/Profile/en-US/?user=myrocodeHow do I send mail using C#?I wrote an article on how you can send emails (bulk mail is also supported) using c#. Yust copy and paste the snippet. <br/><br/><a href="http://www.myrocode.com/post/2009/09/15/Code-Snippet-Send-Bulk-Emails-in-C.aspx">http://www.myrocode.com/post/2009/09/15/Code-Snippet-Send-Bulk-Emails-in-C.aspx</a><br/><br/>you can also add attachment using:<br/><br/><br/>MailAttachment attachment = new MailAttachment( Server.MapPath( &quot;test.txt&quot; ) ); //create the attachment<br/>mail.Attachments.Add( attachment ); //add the attachment<br/><br/>Tue, 15 Sep 2009 08:27:37 Z2009-09-15T08:27:37Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#5fc57b48-9adf-40b4-b2f9-0f508f070ff5http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#5fc57b48-9adf-40b4-b2f9-0f508f070ff5myrocodehttp://social.msdn.microsoft.com/Profile/en-US/?user=myrocodeHow do I send mail using C#?<blockquote>Is it possible to programatically bring up the default email program on a computer and automatically populate the To, Message, Subject, and Attachment fields? <hr class=sig> Peter Harnish</blockquote> <br/>if you are developing an asp.net application you can javascript to open up the default email program and populate To, Message,Subject, but you cannot add attachments.<br/><br/>here's a a method written in c# :<br/><br/><span class=kwrd>private</span> <span class=kwrd>void</span> OpenOutlook(<span class=kwrd>string</span> to, <span class=kwrd>string</span> subject, <span class=kwrd>string</span> cc, <span class=kwrd>string</span> bcc, <span class=kwrd>string</span> body)<br/>{<br/>    <span class=rem>// replace for the newline \n \r<br/></span>    body = body.Replace(&quot;\r&quot;, &quot;%0D&quot;).Replace(&quot;\n&quot;, &quot;%0A&quot;);<br/>    <span class=rem>// build the js<br/></span>    <span class=kwrd>string</span> js = String.Format(@&quot;<br/>    window.onload = function () {{<br/>    var to = '{0}';<br/>    var cc = '{1}';<br/>    var bcc = '{2}';<br/>    var body = '{3}';<br/>    var subject = '{4}';<br/>    var response = 'mailto:'+ to + '?subject='+subject+'&amp;body='+body+'&amp;cc='+cc+'&amp;bcc='+bcc;<br/>    location.href = response;<br/>    window.close();<br/>    }} <br/>    &quot;, to, cc, bcc, body, subject);<br/>    <span class=rem>// register the client js block<br/></span>    <span class=kwrd>this</span>.Page.ClientScript.RegisterClientScriptBlock(<span class=kwrd>this</span>.GetType(), &quot;outlook&quot;, js, <span class=kwrd>true</span>);<br/>} <br/><br/><br/>remember to handler the js's escape charactersTue, 15 Sep 2009 09:27:06 Z2009-09-15T09:27:06Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#0b0f357e-4332-473f-b19d-4bf742450a60http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#0b0f357e-4332-473f-b19d-4bf742450a60Saginihttp://social.msdn.microsoft.com/Profile/en-US/?user=SaginiHow do I send mail using C#?Hi There?<br /> I hope this code snippet I think it may also help u...though meant for SMTP protocol e-mail settings:<br /> <p class="ArticleCode">MailMessage mail = new MailMessage();</p> <p class="ArticleCode">mail.To.Add(&quot;EMAIL REMOVED&quot;);</p> <p class="ArticleCode">mail.From = new MailAddress(&quot;EMAIL REMOVED&quot;);</p> <p class="ArticleCode">mail.Subject = &quot;Test Email&quot;;</p> <p class="ArticleCode">string Body = &quot;Welcome to CodeDigest.Com!!&quot;;</p> <p class="ArticleCode">mail.Body = Body;</p> <p class="ArticleCode">SmtpClient smtp = new SmtpClient();</p> <p class="ArticleCode">smtp.Host = ConfigurationManager.AppSettings[&quot;SMTP&quot;];</p> <p class="ArticleCode">smtp.Send(mail);</p> <p class="ArticleCode">&nbsp;</p> <p class="ArticleCode">Kind Regards</p> <p class="ArticleCode">Sagini</p>Thu, 08 Oct 2009 09:21:45 Z2009-10-08T09:25:03Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#2f11d0ab-39e3-44c3-9ccb-2e3278c5b5b8http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8#2f11d0ab-39e3-44c3-9ccb-2e3278c5b5b8John Bordershttp://social.msdn.microsoft.com/Profile/en-US/?user=John%20BordersHow do I send mail using C#?Just download this <a href="http://www.componentforge.net/smtp.aspx">SMTP Component for .NET</a> and follow its tutorialMon, 02 Nov 2009 09:25:33 Z2009-11-02T09:25:33Z