|
|
|
OutlookApplication in C++ Builder
|
|||
|---|---|---|---|
|
#18+
Как работать при помощи этого компонента(OutlookApplication ) с базой аккаунтов Outlook в C++ Builder ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.10.2006, 08:59 |
|
||
|
OutlookApplication in C++ Builder
|
|||
|---|---|---|---|
|
#18+
http://bdn.borland.com/article/26053 Question How do I use the Microsoft Office servers in C++Builder 5 to automate Outlook? Answer Here is a simple example of using TOutlookApplication to get a list of folders into a TreeView control and display them when the user double-clicks the TreeView. Unit1.h //--------------------------------------------------------------------------- #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include "Outlook_2K_SRVR.h" #include <OleServer.hpp> #include <ComCtrls.hpp> #include <Menus.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TOutlookApplication *ola; TButton *Button1; TTreeView *tv; TLabel *Label1; TPopupMenu *PopupMenu1; TMenuItem *add1; TLabel *Label2; void __fastcall Button1Click(TObject *Sender); void __fastcall tvDblClick(TObject *Sender); void __fastcall add1Click(TObject *Sender); private: // User declarations _NameSpacePtr ns; public: // User declarations __fastcall TForm1(TComponent* Owner); void __fastcall EnumFolders(MAPIFolderPtr fldr, TTreeNode *parent); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif Unit1.cpp //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "Outlook_2K_SRVR" #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { ns = OutlookApplication1->GetNamespace(WideString("MAPI")); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { MAPIFolderPtr tmp; TTreeNode *tmp_node; tv->Items->Clear(); for (int i=1; i<=ns->Folders->Count; i++) { tmp = ns->Folders->Item(i); tmp_node = tv->Items->Add(tv->TopItem,String(tmp->Name)); tmp_node->Data = tmp->EntryID; if (tmp->Folders->Count) EnumFolders(tmp,tmp_node); } } //--------------------------------------------------------------------------- void __fastcall TForm1::EnumFolders(MAPIFolderPtr fldr, TTreeNode *parent) { MAPIFolderPtr tmp; TTreeNode *tmp_node; String str; for (int i=1; i<=fldr->Folders->Count; i++) { tmp = fldr->Folders->Item(i); str = tmp->Name; tmp_node = tv->Items->AddChild(parent,str); tmp_node->Data = tmp->EntryID; if (tmp->Folders->Count) EnumFolders(tmp,tmp_node); } } //--------------------------------------------------------------------------- void __fastcall TForm1::tvDblClick(TObject *Sender) { MAPIFolderPtr fldr; fldr = ns->GetFolderFromID((wchar_t *)tv->Selected->Data); fldr->Display(); } //--------------------------------------------------------------------------- void __fastcall TForm1::add1Click(TObject *Sender) { if (!tv->Selected) return; String fldr_name; MAPIFolderPtr fldr = ns->GetFolderFromID((wchar_t *)tv->Selected->Data); fldr_name = InputBox("enter.folder.name","folder name",""); if (fldr_name != "") fldr->Folders->Add(WideString(fldr_name)); } //--------------------------------------------------------------------------- ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.10.2006, 13:05 |
|
||
|
|

start [/forum/topic.php?fid=57&msg=34078893&tid=2030196]: |
0ms |
get settings: |
6ms |
get forum list: |
8ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
260ms |
get topic data: |
7ms |
get forum data: |
2ms |
get page messages: |
26ms |
get tp. blocked users: |
1ms |
| others: | 191ms |
| total: | 505ms |

| 0 / 0 |
