Microsoft KB Archive/310233

= HOW TO: Send Mail with Proxy Server That Is Configured Manually by Using Collaboration Data Objects for Windows in Visual C# .NET =

Article ID: 310233

Article Last Modified on 11/29/2007

-

APPLIES TO


 * Microsoft Collaboration Data Objects 2.0
 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7

-



This article was previously published under Q310233



Caution ADO and ADO MD have not been fully tested in a Microsoft .NET Framework environment. They may cause intermittent issues, especially in service-based applications or in multithreaded applications. The techniques that are discussed in this article should only be used as a temporary measure during migration to ADO.NET. You should only use these techniques after you have conducted complete testing to make sure that there are no compatibility issues. Any issues that are caused by using ADO or ADO MD in this manner are unsupported. For more information, see the following article in the Microsoft Knowledge Base:

840667 You receive unexpected errors when using ADO and ADO MD in a .NET Framework application



IN THIS TASK
SUMMARY
 * Send Mail with a Proxy Server That Is Configured Manually

REFERENCES



SUMMARY
This article describes how to use Microsoft Collaboration Data Objects (CDO) for Windows Library in Visual C# .NET to send an e-mail message with a proxy server that is configured manually.

back to the top

Send Mail with a Proxy Server That Is Configured Manually
 Start Microsoft Visual Studio .NET. On the File menu, point to New, and then click Project. Click Visual C# Projects under Project Types, and then click Console Application under Templates. By default, Class1.cs is created. Add a reference to the Microsoft CDO for Windows 2000 Library and the Microsoft ActiveX Data Objects 2. Library. To do this, follow these steps:  On the Project menu, click Add Reference. Click the COM tab.</li> Click Microsoft CDO for Windows 2000 Library, and then click Select.</li> Click '''Microsoft ActiveX Data Objects 2. Library, and then click Select'''.</li> Click OK. If you are prompted to generate wrappers for the libraries that you selected, click Yes.</li></ol> </li>  In the Code window, replace the default code with the following code: namespace CdoSys {   using System; class Class1 {       static void Main(string[] args) {           try {                      CDO.Message oMsg = new CDO.Message; CDO.Configuration iConfg = new CDO.Configuration; ADODB.Fields oFields; ADODB.Field oField;

oFields = iConfg.Fields;

// Set Proxy properties oField = oFields[&quot;http://schemas.microsoft.com/cdo/configuration/urlproxyserver&quot;]; oField.Value = &quot;itgproxy&quot;;

oField = oFields[&quot;http://schemas.microsoft.com/cdo/configuration/proxyserverport&quot;]; oField.Value = 80;

oField = oFields[&quot;http://schemas.microsoft.com/cdo/configuration/smtpsserver&quot;]; oField.Value = &quot;smarthost&quot;;

oField = oFields[&quot;http://schemas.microsoft.com/cdo/configuration/smtpserverport&quot;]; oField.Value =25; oFields.Update;

oMsg.Configuration = iConfg;

// Set common properties for Message oMsg.Subject = &quot;Test SMTP&quot;; oMsg.From = &quot;from@microsoft.com&quot;; oMsg.To = &quot;to@microsoft.com&quot;;

oMsg.Send; }           catch (Exception e)            { Console.WriteLine(&quot;{0} Exception caught.&quot;, e); }           return; }   } }                    </li> Modify the code where you see the TODO comments.</li> Press F5 to build and to run the application.</li> Verify that the e-mail message is sent and received.</li></ol>

back to the top

<div class="references_section">