Click to See Complete Forum and Search --> : How to get contact address from outlook?


seacyclone
October 31st, 2005, 05:05 AM
I want to get contact email from outlook in my program.
Who can help me?
Thanks!

PeejAvery
October 31st, 2005, 07:21 AM
Can you be more specific? What language do you want to write this in?

seacyclone
October 31st, 2005, 11:56 PM
How to do in MFC?
Thanks!

PeejAvery
November 1st, 2005, 12:06 AM
MFC as in Visual C++? If so, you should ask a supermoderator to move this thread to the C++ forum.

Sahir
November 1st, 2005, 03:39 AM
#import "C:\Program Files\Common Files\Microsoft Shared\OFFICE11\mso.dll" \
no_namespace
#import "C:\Program Files\Microsoft Office\OFFICE11\msoutl.olb" \
rename_namespace("Outlook")

#pragma warning(default:4146)

void CDialogTestDlg::OnButton1()
{
::CoInitialize(NULL);
Outlook::_ApplicationPtr app("Outlook.Application");
Outlook::_NameSpacePtr ns = app->GetNamespace("MAPI");
Outlook::MAPIFolderPtr fldr = ns->GetDefaultFolder(olFolderContacts);
Outlook::_ItemsPtr items = fldr->GetItems ();
Outlook::_ContactItemPtr ctc;
ctc = items->GetFirst();
List1.InsertString(-1, (LPCSTR) ctc->GetFullName());
for(int j = 1; j < items->GetCount(); j++) {
ctc = items->GetNext();
List1.InsertString(-1, (LPCSTR) ctc->GetFullName());
}
}