Mega Code Archive

 
Categories / Delphi / Activex OLE
 

How to create a new Outlook contact item

Title: How to create a new Outlook contact item uses ComObj, Outlook2000; {$ELSE} uses ComObj, Outlook8; {$ENDIF} procedure NewContactItem; var OutlApp: OutlookApplication; OutlNamespace: Namespace; ContactFolder: MAPIFolder; Contact: ContactItem; begin OutlApp := CoOutlookApplication.Create; OutlNamespace := OutlApp.GetNameSpace('MAPI'); ContactFolder := OutlNamespace.GetDefaultFolder(olFolderContacts); Contact := OutlApp.createitem(olContactItem) as ContactItem; Contact.LastName := 'User'; Contact.FirstName := 'Jack'; Contact.HomeAddressStreet := 'Street'; Contact.HomeAddressCountry := 'Germany'; Contact.HomeAddressPostalCode := '12345'; Contact.HomeAddressCity := 'City'; Contact.HomeTelephoneNumber := '+49(0)1239/23903'; Contact.HomeFaxNumber := '+49(0)1239/23904'; Contact.Email1Address := 'info@user.com'; Contact.Save; OutlApp := nil; end; procedure TForm1.Button1Click(Sender: TObject); begin NewContactItem; end;