PC Review


Reply
Thread Tools Rate Thread

adding a contact(name) to a new created journal in visual c++

 
 
Martin Schroll
Guest
Posts: n/a
 
      19th Jan 2004
hello there,

i have a problem with adding a contact to my new journal.
When i use JournalItem.SetContactNames(strContact);
the form doesn't show the contact name in the contact-box.
Now i have read that you must use "olItem.Links.Add" in vb. But i
don`t know how to do "oItem.Links.Add" in vc++, because there is no
Links-property on my JournalItem-object.

thanks for support
Martin
 
Reply With Quote
 
 
 
 
Martin Schroll
Guest
Posts: n/a
 
      21st Jan 2004
Now i have found a possible solution for this problem:


CString COutlookKontakte::OpenNewJournal(CString strLoggedUsername,
USERDATA UserArray[])
{
CString EntryIDResult="";
_Application olApp;
COleException error;

try{
// if it is already running, we'll use the same instance
if(!olApp.CreateDispatch("Outlook.Application", &error)){
CString str;
str.Format("CreateDispatch() failed w/error 0x%08lx", error.m_sc);
AfxMessageBox(str, MB_SETFOREGROUND);
return EntryIDResult;
}

// logon
_NameSpace olNs(olApp.GetNamespace("MAPI"));
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
olNs.Logon(covOptional, covOptional, covOptional, covOptional);

// open default outlook contacts folder
MAPIFolder myContactsFolder(olNs.GetDefaultFolder(10));
if(myContactsFolder==NULL){
AfxMessageBox("Could not find default contact
folder!",MB_ICONEXCLAMATION);
return EntryIDResult;
}

// get the items from the folder
_Items myItems(myContactsFolder.GetItems());
if(myItems==NULL){
AfxMessageBox("Unable to get contact items!", MB_ICONEXCLAMATION);
return EntryIDResult;
}

// get the right contact item
_ContactItem myContactItem(olApp.CreateItem(2));
CString strFind;
strFind.Format("[FirstName]=\"%s\" and [LastName]=\"%s\"",
UserArray[0].Vorname, UserArray[0].Nachname);
if(!(myContactItem=myItems.Find(strFind))){
AfxMessageBox(APP->m_rl.Load(IDS_MSGBOX_DS), MB_ICONEXCLAMATION);
return EntryIDResult;
}

// create and open a new journal
_JournalItem JournalItem(olApp.CreateItem(4));
VARIANT vt;
vt.vt=VT_BOOL;
vt.boolVal=FALSE;
CString strBody=APP->m_rl.Load(IDS_STRING_ADV)+strLoggedUsername;
JournalItem.SetBody(strBody);
Links myLinkCol=JournalItem.GetLinks();
myLinkCol.Add(myContactItem.m_lpDispatch);
JournalItem.StartTimer();
JournalItem.Save();
JournalItem.Display(vt);
EntryIDResult=JournalItem.GetEntryID();
olNs.Logoff();
}
catch(COleException *e){
e->Delete();
AfxMessageBox(APP->m_rl.Load(IDS_MSGBOX_ERROR) + "
'OpenNewJournal'!", MB_ICONERROR);
return EntryIDResult;
}
return EntryIDResult;
}
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing default contacts when adding a contact to a journal entry reha Microsoft Outlook Discussion 3 12th Mar 2009 06:35 PM
Adding journal entry to contact, appears in ALL contacts activies. =?Utf-8?B?S2VsdmluX0lwc3dpY2g=?= Microsoft Outlook Contacts 0 23rd Feb 2005 01:01 PM
Journal, adding a contact button nevents Microsoft Outlook Form Programming 1 10th Feb 2004 01:12 PM
Adding a Contact field in Journal folder view Glenn Microsoft Outlook Discussion 1 23rd Jan 2004 10:36 PM
Re: seeing contact list as a delegate adding a journal entry Sue Mosher [MVP] Microsoft Outlook Discussion 0 7th Jul 2003 01:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:35 AM.