PDT+bug 80446 Importing Outlook Contacts doesn't import email addresses,
r=Cyrille.Moureaux@Sun.com, sr=mscott git-svn-id: svn://10.0.0.236/branches/MOZILLA_0_9_2_BRANCH@98906 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -622,10 +622,20 @@ void CMapiApi::ListProperties( LPMAPIPROP lpProp, BOOL getValues)
|
||||
MAPI_TRACE0( " Unable to retrieve property list\n");
|
||||
return;
|
||||
}
|
||||
ULONG count = 0;
|
||||
LPMAPINAMEID FAR * lppPropNames;
|
||||
SPropTagArray tagArray;
|
||||
LPSPropTagArray lpTagArray = &tagArray;
|
||||
tagArray.cValues = (ULONG)1;
|
||||
nsCString desc;
|
||||
for (ULONG i = 0; i < pArray->cValues; i++) {
|
||||
GetPropTagName( pArray->aulPropTag[i], desc);
|
||||
if (getValues) {
|
||||
tagArray.aulPropTag[0] = pArray->aulPropTag[i];
|
||||
hr = lpProp->GetNamesFromIDs(&lpTagArray, nsnull, 0, &count, &lppPropNames);
|
||||
if (hr == S_OK)
|
||||
MAPIFreeBuffer(lppPropNames);
|
||||
|
||||
LPSPropValue pVal = GetMapiProperty( lpProp, pArray->aulPropTag[i]);
|
||||
if (pVal) {
|
||||
desc += ", ";
|
||||
@@ -639,6 +649,31 @@ void CMapiApi::ListProperties( LPMAPIPROP lpProp, BOOL getValues)
|
||||
MAPIFreeBuffer( pArray);
|
||||
}
|
||||
|
||||
ULONG CMapiApi::GetEmailPropertyTag(LPMAPIPROP lpProp, LONG nameID)
|
||||
{
|
||||
static GUID emailGUID = {
|
||||
0x00062004, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46
|
||||
};
|
||||
|
||||
MAPINAMEID mapiNameID;
|
||||
mapiNameID.lpguid = &emailGUID;
|
||||
mapiNameID.ulKind = MNID_ID;
|
||||
mapiNameID.Kind.lID = nameID;
|
||||
|
||||
LPMAPINAMEID lpMapiNames = &mapiNameID;
|
||||
LPSPropTagArray lpMailTagArray = nsnull;
|
||||
|
||||
HRESULT result = lpProp->GetIDsFromNames(1L, &lpMapiNames, 0, &lpMailTagArray);
|
||||
if (result == S_OK)
|
||||
{
|
||||
ULONG lTag = lpMailTagArray->aulPropTag[0];
|
||||
MAPIFreeBuffer(lpMailTagArray);
|
||||
return lTag;
|
||||
}
|
||||
else
|
||||
return 0L;
|
||||
}
|
||||
|
||||
BOOL CMapiApi::HandleHierarchyItem( ULONG oType, ULONG cb, LPENTRYID pEntry)
|
||||
{
|
||||
if (oType == MAPI_FOLDER) {
|
||||
|
||||
@@ -103,6 +103,8 @@ public:
|
||||
static BOOL GetLargeStringProperty( LPMAPIPROP pProp, ULONG tag, nsCString& val);
|
||||
static BOOL GetLargeStringProperty( LPMAPIPROP pProp, ULONG tag, nsString& val);
|
||||
static BOOL IsLargeProperty( LPSPropValue pVal);
|
||||
static ULONG GetEmailPropertyTag(LPMAPIPROP lpProp, LONG nameID);
|
||||
|
||||
|
||||
// Debugging & reporting stuff
|
||||
static void ListProperties( LPMAPIPROP lpProp, BOOL getValues = TRUE);
|
||||
|
||||
@@ -95,6 +95,19 @@ static MAPIFields gMapiFields[] = {
|
||||
|
||||
#define kCopyBufferSize (16 * 1024)
|
||||
|
||||
// The email address in Outlook Contacts doesn't have a named
|
||||
// property, we need to use this mapi name ID to access the email
|
||||
// The MAPINAMEID for email address has ulKind=MNID_ID
|
||||
// Outlook stores each email address in two IDs, 32899/32900 for Email1
|
||||
// 32915/32916 for Email2, 32931/32932 for Email3
|
||||
// Current we use OUTLOOK_EMAIL1_MAPI_ID1 for primary email
|
||||
// OUTLOOK_EMAIL2_MAPI_ID1 for secondary email
|
||||
#define OUTLOOK_EMAIL1_MAPI_ID1 32899
|
||||
#define OUTLOOK_EMAIL1_MAPI_ID2 32900
|
||||
#define OUTLOOK_EMAIL2_MAPI_ID1 32915
|
||||
#define OUTLOOK_EMAIL2_MAPI_ID2 32916
|
||||
#define OUTLOOK_EMAIL3_MAPI_ID1 32931
|
||||
#define OUTLOOK_EMAIL3_MAPI_ID2 32932
|
||||
|
||||
nsOutlookMail::nsOutlookMail()
|
||||
{
|
||||
@@ -362,7 +375,7 @@ nsresult nsOutlookMail::ImportMailbox( PRUint32 *pDoneSoFar, PRBool *pAbort, PRI
|
||||
ULONG cbEid;
|
||||
LPENTRYID lpEid;
|
||||
ULONG oType;
|
||||
LPMESSAGE lpMsg;
|
||||
LPMESSAGE lpMsg = nsnull;
|
||||
int attachCount;
|
||||
ULONG totalCount;
|
||||
PRFloat64 doneCalc;
|
||||
@@ -992,13 +1005,31 @@ PRBool nsOutlookMail::BuildCard( const PRUnichar *pName, nsIAddrDatabase *pDb, n
|
||||
nsString eMail;
|
||||
nsString nickName;
|
||||
nsString middleName;
|
||||
nsString secondEMail;
|
||||
ULONG emailTag;
|
||||
|
||||
LPSPropValue pProp = m_mapi.GetMapiProperty( pUser, PR_EMAIL_ADDRESS);
|
||||
if (!pProp) {
|
||||
emailTag = m_mapi.GetEmailPropertyTag(pUser, OUTLOOK_EMAIL1_MAPI_ID1);
|
||||
if (emailTag) {
|
||||
pProp = m_mapi.GetMapiProperty( pUser, emailTag);
|
||||
}
|
||||
}
|
||||
if (pProp) {
|
||||
m_mapi.GetStringFromProp( pProp, eMail);
|
||||
SanitizeValue( eMail);
|
||||
}
|
||||
|
||||
// for secondary email
|
||||
emailTag = m_mapi.GetEmailPropertyTag(pUser, OUTLOOK_EMAIL2_MAPI_ID1);
|
||||
if (emailTag) {
|
||||
pProp = m_mapi.GetMapiProperty( pUser, emailTag);
|
||||
if (pProp) {
|
||||
m_mapi.GetStringFromProp( pProp, secondEMail);
|
||||
SanitizeValue( secondEMail);
|
||||
}
|
||||
}
|
||||
|
||||
pProp = m_mapi.GetMapiProperty( pUser, PR_GIVEN_NAME);
|
||||
if (pProp) {
|
||||
m_mapi.GetStringFromProp( pProp, firstName);
|
||||
@@ -1068,6 +1099,10 @@ PRBool nsOutlookMail::BuildCard( const PRUnichar *pName, nsIAddrDatabase *pDb, n
|
||||
pDb->AddPrimaryEmail( newRow, pCStr = eMail.ToNewUTF8String());
|
||||
nsCRT::free( pCStr);
|
||||
}
|
||||
if (!secondEMail.IsEmpty()) {
|
||||
pDb->Add2ndEmail( newRow, pCStr = secondEMail.ToNewUTF8String());
|
||||
nsCRT::free( pCStr);
|
||||
}
|
||||
|
||||
// Do all of the extra fields!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user