C++ application using automation via #import directive no longer compiles with newer Outlook version

  • Thread starter Thread starter Zed El
  • Start date Start date
Z

Zed El

Guest
Hello All,

I have a compilation issue that just recently arose on one of my colleagues machines. The difference between our machines is his Outlook version is 1808 (build 10730.20102), and mine is version 1803 (build 9126.2295). I have no issues building with outlook 1803, these are the compile errors on the outlook 1808 machine:


1>d:\win32contacts\debug\msoutl.tlh(6759) : error C2146: syntax error : missing ';' before identifier 'PickerDialog'

1>d:\win32contacts\debug\msoutl.tlh(6759) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>d:\win32contacts\debug\msoutl.tlh(6759) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>d:\win32contacts\debug\msoutl.tlh(6844) : error C2146: syntax error : missing ';' before identifier 'GetPickerDialog'

1>d:\win32contacts\debug\msoutl.tlh(6844) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>d:\win32contacts\debug\msoutl.tlh(6844) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>d:\win32contacts\debug\msoutl.tlh(6844) : warning C4183: 'GetPickerDialog': missing return type; assumed to be a member function returning 'int'

1>d:\win32contacts\debug\msoutl.tlh(7068) : error C2146: syntax error : missing ';' before identifier 'CreateContactCard'

1>d:\win32contacts\debug\msoutl.tlh(7068) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>d:\win32contacts\debug\msoutl.tlh(7069) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>d:\win32contacts\debug\msoutl.tlh(7069) : warning C4183: 'CreateContactCard': missing return type; assumed to be a member function returning 'int'

1>d:\win32contacts\debug\msoutl.tlh(28085) : error C2143: syntax error : missing ';' before 'Outlook::_Application::GetPickerDialog'

1>d:\win32contacts\debug\msoutl.tlh(28085) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>d:\win32contacts\debug\msoutl.tlh(28085) : error C2497: 'PickerDialogPtr' : 'implementation_key' can only be applied to function declarations

1>d:\win32contacts\debug\msoutl.tlh(28085) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>d:\win32contacts\debug\msoutl.tlh(28132) : error C2143: syntax error : missing ';' before 'Outlook::_NameSpace::CreateContactCard'

1>d:\win32contacts\debug\msoutl.tlh(28132) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>d:\win32contacts\debug\msoutl.tlh(28132) : error C2497: 'ContactCardPtr' : 'implementation_key' can only be applied to function declarations

1>d:\win32contacts\debug\msoutl.tlh(28132) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

This is some of the source code (it's from code project: https://www.codeproject.com/Articles/3695/Importing-contacts-from-Outlook)

// OutlookContactsDlg.cpp : implementation file
//

#include "stdafx.h"
#include "OutlookContacts.h"
#include "OutlookContactsDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#import <mso.dll> no_namespace rename("DocumentProperties", "DocumentPropertiesOUTL") rename("RGB", "RBGOUTL")
#import <msoutl.olb> rename_namespace("Outlook") rename("CopyFile", "CopyFileOTL") rename("PlaySound", "PlaySoundOTL") rename("GetOrganizer", "GetOrganizerAE")

using namespace Outlook;
/////////////////////////////////////////////////////////////////////////////
// COutlookContactsDlg dialog

COutlookContactsDlg::COutlookContactsDlg(CWnd* pParent /*=NULL*/)
: CDialog(COutlookContactsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(COutlookContactsDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void COutlookContactsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COutlookContactsDlg)
DDX_Control(pDX,IDC_CONTACTLIST,m_ContactList);
DDX_Control(pDX,IDC_OPTION,m_Option);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(COutlookContactsDlg, CDialog)
//{{AFX_MSG_MAP(COutlookContactsDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_IMPORT, OnImport)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COutlookContactsDlg message handlers

BOOL COutlookContactsDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

return TRUE; // return TRUE unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void COutlookContactsDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

HCURSOR COutlookContactsDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void COutlookContactsDlg::OnImport()
{

_ApplicationPtr pApp;
_ItemsPtr pItems;
MAPIFolderPtr pFolder;
_ContactItemPtr pContact;

HRESULT hr;

try
{
hr=pApp.CreateInstance(__uuidof(Application));
if (FAILED(hr))
{
MessageBox(_T("Unable to instantiate Outlook."),_T("Outlook Error"),MB_OK);
return;
}

if (m_Option.GetCheck()) //default outlook contacts folder
{
pFolder=pApp->GetNamespace(_bstr_t("MAPI"))->GetDefaultFolder(olFolderContacts);
if (pFolder==NULL)
{
MessageBox(_T("Could not find default contacts folder."),_T("Outlook Error"));
return;
}
}
else //display folder selection window
{
pFolder=pApp->GetNamespace(_bstr_t("MAPI"))->PickFolder();
if (pFolder==NULL)
return;

if (pFolder->GetDefaultItemType()!=olContactItem)
{
MessageBox(_T("Select folder is not a Contact folder."),_T("Outlook Contacts"));
return;
}
}


pItems=pFolder->GetItems();
if (pItems==NULL)
{
MessageBox(_T("Unabel to get Contact Items."),_T("Outlook Error"));
return;
}

pContact=pItems->GetFirst();


m_ContactList.ResetContent();

while(1)
{
if (pContact==NULL)
break;
CString strTemp;
strTemp=(char *)pContact->GetFullName();
strTemp=strTemp + "<";
strTemp=strTemp + (char *)pContact->GetEmail1Address();
strTemp=strTemp + ">";
m_ContactList.AddString(strTemp);

pContact=pItems->GetNext();
}

}
catch(_com_error &e)
{
MessageBox(e.Description());
}
}



I've tried excluding the offending items to no avail. So far there's only one machine that has this updated version of Outlook, but our IT department could update everyone's machine in time, which will be a problem. Does anyone know how I can fix this?

Thanks.

Continue reading...
 
Back
Top