HOW TO: Send Mail with Proxy Server That Is Configured Manually by Using Collaboration Data Objects for Windows in Visual C# .NET (310233)
The information in this article applies to:
- Microsoft Collaboration Data Objects for Windows 2000
- Microsoft Visual C# .NET (2002)
- ActiveX Data Objects (ADO) 2.5
- ActiveX Data Objects (ADO) 2.6
- ActiveX Data Objects (ADO) 2.7
This article was previously published under Q310233 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.x Library. To do this, follow these steps:
- On the Project menu, click Add Reference.
- Click the COM tab.
- Click Microsoft CDO for Windows 2000 Library, and then click Select.
- Click Microsoft ActiveX Data Objects 2.x Library, and then click Select.
- Click OK. If you are prompted to generate wrappers for the libraries that you selected, click Yes.
- 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["http://schemas.microsoft.com/cdo/configuration/urlproxyserver"];
oField.Value = "itgproxy";
oField = oFields["http://schemas.microsoft.com/cdo/configuration/proxyserverport"];
oField.Value = 80;
oField =
oFields["http://schemas.microsoft.com/cdo/configuration/smtpsserver"];
oField.Value = "smarthost";
oField =
oFields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"];
oField.Value =25;
oFields.Update();
oMsg.Configuration = iConfg;
// Set common properties for Message
oMsg.Subject = "Test SMTP";
oMsg.From = "from@microsoft.com";
oMsg.To = "to@microsoft.com";
oMsg.Send();
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
return;
}
}
}
- Modify the code where you see the TODO comments.
- Press F5 to build and to run the application.
- Verify that the e-mail message is sent and received.
back to the top
REFERENCES
For more information, visit the following Microsoft Developer Network (MSDN) Web site:
back to the top
Modification Type: | Major | Last Reviewed: | 1/19/2006 |
---|
Keywords: | kbHOWTOmaster KB310233 kbAudDeveloper |
---|
|