Home   |   Asp.Net 2.0   |   .Net Framework 2.0   |   IIS 6.0   |   Sql Server 2005   |   Visual Basic 2005   |   c# 2005   |   VS 2005   |   Visual Source Safe 2005

MS Dynamics CRM 3.0

SharePoint Portal Server 2003
SharePoint Server 2007
Dynamics NAV
Dynamics CRM
SharePoint Designer 2007
SharePoint Portal Server 2001
Windows SharePoint Services
Windows SharePoint Services 3.0
Project Server 2003
Project Server 2007
Dynamics – Point of Sale
Dynamics AX
Dynamics GP
Dynamics Retail Management System (RMS)
Dynamics SL
SQL Server 2000
Visual Basic .NET 2003
Visual C# .NET 2003
Visual C++ .NET 2003
Visual C++ 2005
Visual SourceSafe 6.0
Windows Server 2003
Windows Server 2003
Outlook 2003
ADO.NET 1.1
ASP.NET 1.0
Visual Studio Team Foundation Server
Visual Studio 2005 Team Edition
Windows Internet Explorer 7
BizTalk Server 2000
BizTalk Server 2002
BizTalk Server 2004
BizTalk Server 2006
Visual Studio 6.0
Access 2000
Access 2002
Access 2003
Access 2007
Access 97
Collaboration Data Objects 2.0
Commerce Server 2002
Content Management Server 2001
Commerce Server 2007
Content Management Server 2002
Data Access Components 2.7
Data Access Components 2.8
DirectX 9.0b
Office Small Business Accounting 2006
Accounting 2007
ActiveSync 4.1
Class Server 2.0
Groove 2007
Windows Vista
Outlook 2007
OneNote 2003
OneNote 2007
Office X for Mac
Zune software
Zune Live
Zoo Tycoon 2
Flight Simulator 2002
Dungeon Siege II

Cervo Technologies
The Right Source to Outsource

Oracle Database FAQS

Sharepoint Portal Server KB

Outlook 2007 Knowledge Base Articles

Collaboration Data Objects 2.0 Knowledge Base Articles

Describes how to use the CDO for Windows 2000 library to process mail in the Drop directory. This article demonstrates how to do this by using a step-by-step Visual C# .NET sample. Processing mail includes three actions: Reply, Reply All, and Forward.


This article describes how to use Microsoft Collaboration Data Objects (CDO) for Windows 2000 library (Cdosys.dll) to act on a message. This article describes how to act on a message in Microsoft Visual C# .NET or Microsoft Visual C# 2005. To act on a message, you can do any one of the following:
You can click Reply.
You can click Reply All.
You can click Forward.
Note The Cdosys.dll library is also known as CDOSYS.

MORE INFORMATION

To use CDOSYS to act on a message, follow these steps:
1.Start Microsoft Visual Studio .NET or Microsoft Visual C# 2005.
2.On the File menu, click New, and then click Project.
3.Click Console Application in the Visual C# Projects types list.

Note In Microsoft Visual C# 2005, click Console Application in the Visual C# 2005 list.

In Visual Studio .NET, Class1.cs is created by default. In Visual Studio 2005, Program.cs is created by default.
4.Add a reference to the Microsoft CDO For Windows 2000 Library.

To do this, follow these steps:
a. On the Project menu, click Add Reference.
b. On the COM tab, click Microsoft CDO For Windows 2000 Library, and then click Select.

Note In Visual Studio 2005, you do not have to click Select.
c. In the Add References dialog box, click OK to accept your selections.

If you receive a message to generate wrappers for the libraries that you selected, click Yes.
5.In the Code window, replace all the code with the following code:
namespace CdoSys
{
    using System;
    class Class1
    {
        static void Main(string[] args)
        {
            try 
            {           
                CDO.DropDirectory iDropDir = new CDO.DropDirectory();
                CDO.IMessages iMsgs;
 
                CDO.IMessage iMsgReply;
                CDO.IMessage iMsgReplyAll;
                CDO.IMessage iMsgForward;

                // Get the messages from the Drop directory.
                iMsgs = iDropDir.GetMessages("C:\\Inetpub\\mailroot\\Drop");
                Console.WriteLine("Messages Count : " + iMsgs.Count.ToString());

                foreach (CDO.IMessage iMsg in iMsgs)
                {
                    Console.WriteLine(iMsgs.get_FileName(iMsg));

                    // Output some common properties of the extracted message.
                    Console.WriteLine("Subject: " + iMsg.Subject);
                    Console.WriteLine("TextBody: " + iMsg.TextBody);
                    Console.WriteLine("datereceived: " + iMsg.Fields["urn:schemas:httpmail:datereceived"].Value);
                    Console.WriteLine("sendername: " + iMsg.Fields["urn:schemas:httpmail:sendername"].Value);
                    Console.WriteLine("senderemail: " + iMsg.Fields["urn:schemas:httpmail:senderemail"].Value);
                    Console.WriteLine("from: " + iMsg.Fields["urn:schemas:httpmail:from"].Value);
                    Console.WriteLine("sender: " + iMsg.Fields["urn:schemas:httpmail:sender"].Value);

                    // Reply.
                    iMsgReply = iMsg.Reply();
          
                    // TODO: Change "rhaddock@northwindtraders.com" to your e-mail address.
                    iMsgReply.From = "rhaddock@northwindtraders.com";
                    iMsgReply.TextBody = "I agree. You can continue." + "\n\n" + iMsgReply.TextBody;
                    iMsgReply.Send();

                    // This is ReplyAll.
                    iMsgReplyAll = iMsg.ReplyAll();

                    // TODO: Change "rhaddock@northwindtraders.com" to your e-mail address.
                    iMsgReplyAll.From = "rhaddock@northwindtraders.com";
                    iMsgReplyAll.TextBody = "I agree. You can continue" + "\n\n" + iMsgReplyAll.TextBody;
                    iMsgReplyAll.Send();

                    // This is Forward.
                    iMsgForward = iMsg.Forward();
            
                    // TODO: Change "rhaddock@northwindtraders.com" to your e-mail address.
                    iMsgForward.From = "rhaddock@northwindtraders.com";
                    // TODO: Change "Jonathan@northwindtraders.com" to the address that you want to forward to.
                    iMsgForward.To = "Jonathan@northwindtraders.com";
                    iMsgForward.TextBody = "You missed this." + "\n\n" + iMsgForward.TextBody;
                    iMsgForward.Send();
                }

                // Clean up memory.
                iMsgs = null;
                iMsgReply = null;
                iMsgReplyAll = null;
                iMsgForward = null;
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
            }
            return;
        }
    }
} 
6.Where "TODO:" appears in the previous sample code, modify the code as indicated.
7.Press F5 to build and to run the program.

REFERENCES

For additional information about Microsoft Office development with Visual Studio, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoxpta/html/vsofficedev.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoxpta/html/vsofficedev.asp)
For additional information about how to use CDOSYS, click the following article numbers to view the articles in the Microsoft Knowledge Base:


APPLIES TO
Microsoft Visual C# 2005
Microsoft Visual C# .NET 2003 Standard Edition
Microsoft Visual C# .NET 2002 Standard Edition
Microsoft Collaboration Data Objects 2.0
Microsoft ActiveX Data Objects 2.5
Microsoft ActiveX Data Objects 2.6
Microsoft ActiveX Data Objects 2.7
Microsoft Internet Information Services 6.0
Microsoft Internet Information Services 5.0

Keywords: 
kbsample kbcode kbhowto KB310224

Copyright © 2004 - 2007 Gridview.org, Inc. All rights reserved. Powered by Smart Web Content Management System