Page 1 of 1
How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??
Posted: Sat Apr 06, 2019 2:04 pm
by rn@warner-it.com
FUNCTION AddNewContact() AS VOID
LOCAL oApp AS Microsoft.Office.Interop.Outlook.Application
oApp := CreateObject(Outlook.Application)
LOCAL oNs AS Microsoft.Office.Interop.Outlook.NameSpace
oNs = oApp.GetNamespace("MAPI")
oNs.Logon()
LOCAL oItem AS Outlook.ContactItem
oItem = oApp.CreateItem(OlItemType.olContactItem)
oItem.FullName := _OutlookSNamecontact
oItem.CompanyName := M_Custname
oItem.Email1Address := _OutlookEmailcontact
oItem.JobTitle := _OutlookFunction
oItem.HomeAddress := "Europe Germany"
oItem.BusinessAddress := "Europe Germany"
oItem.Email1Address := _OutlookEmailcontact
oItem.Save()
RETURN
How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??
Posted: Sat Apr 06, 2019 3:40 pm
by wriedmann
Hi Raymond,
your code has ever worked?
On my machine, the following code creates a contact:
Code: Select all
local oApp as Microsoft.Office.Interop.Outlook.Application
local oItem as _ContactItem
oApp := Microsoft.Office.Interop.Outlook.Application{}
oItem := oApp.CreateItem( OlItemType.olContactItem )
oItem.FullName := "Raymond Nathan Warner"
oItem.Save()
as you can see here:
- newcontact.png (30.54 KiB) Viewed 874 times
Wolfgang
How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??
Posted: Sat Apr 06, 2019 4:46 pm
by rn@warner-it.com
HI Wolfgang,
Thank you so much for your help I tried to do the same with your code and have this as a result I am pasting this in here.
This is the error message I get when I compile this code
error XS0266: Cannot implicitly convert type 'object' to 'Microsoft.Office.Interop.Outlook._ContactItem'. An explicit conversion exists (are you missing a cast?) 150,10 Ray_Outlook.prg FormApp6
FUNCTION AddNewContact() AS VOID
LOCAL oApp AS Microsoft.Office.Interop.Outlook.Application
LOCAL oItem AS _ContactItem
oApp := Microsoft.Office.Interop.Outlook.Application{}
oItem := oApp.CreateItem( OlItemType.olContactItem )
oItem.FirstName := _OutlookFnamecontact
oItem.FullName := _OutlookSNamecontact
oItem.Title := _OutlookFunction
oItem.Birthday := Convert.ToDateTime("5/4/1969")
oItem.CompanyName := M_Custname
oItem.Department := "Development"
* NewContact.Body := "Sample"
*NewContact.FileAs := "Authorcode"
oItem.Email1Address := _OutlookEmailcontact
oItem.BusinessTelephoneNumber := _OutlookTel
oItem.MobileTelephoneNumber := _OutlookMobile
oItem.MailingAddress := _OutlookEmailcontact
oItem.Subject := "Contact created from X#"
oItem.JobTitle := _OutlookFunction
*oItem.FullName := "Raymond Nathan Warner"
oItem.Save()
RETURN
How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??
Posted: Sat Apr 06, 2019 6:59 pm
by wriedmann
Hi Raymond,
I have to check tomorrow morning.
It is strange - on my machine it compiles without any error. Maybe this is my version of the MSOutl.dll.
WOlfgang
How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??Hi
Posted: Sat Apr 06, 2019 8:58 pm
by rn@warner-it.com
Hi Wolfgang
I tried other possibilities but all in vain I hope you come up with a solution I cannot use my other modules for Outlook until I solve this one. The only thing that works currently Outlook is to send a mail.
Thanks and Regards,
Raymond
How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??Hi
Posted: Sat Apr 06, 2019 8:58 pm
by rn@warner-it.com
Hi Wolfgang
I tried other possibilities but all in vain I hope you come up with a solution I cannot use my other modules for Outlook until I solve this one. The only thing that works currently Outlook is to send a mail.
Thanks and Regards,
Raymond
How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??Hi
Posted: Sun Apr 07, 2019 5:13 am
by wriedmann
Hi Raymond,
only to make it sure: I cannot come up with a solution. I can only help you to find your solution.
I have attached a working sample as XIDE export file to this message, and included also the Outlook interop library that I have generated from my installed Outlook 2010.
Maybe you are including the wrong library/DLL in your application.
Wolfgang
How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??
Posted: Sun Apr 07, 2019 12:04 pm
by Chris
rn@warner-it.com wrote:HI Wolfgang,
Thank you so much for your help I tried to do the same with your code and have this as a result I am pasting this in here.
This is the error message I get when I compile this code
error XS0266: Cannot implicitly convert type 'object' to 'Microsoft.Office.Interop.Outlook._ContactItem'. An explicit conversion exists (are you missing a cast?) 150,10 Ray_Outlook.prg FormApp6
FUNCTION AddNewContact() AS VOID
LOCAL oApp AS Microsoft.Office.Interop.Outlook.Application
LOCAL oItem AS _ContactItem
oApp := Microsoft.Office.Interop.Outlook.Application{}
oItem := oApp.CreateItem( OlItemType.olContactItem )
oItem.FirstName := _OutlookFnamecontact
oItem.FullName := _OutlookSNamecontact
oItem.Title := _OutlookFunction
oItem.Birthday := Convert.ToDateTime("5/4/1969")
oItem.CompanyName := M_Custname
oItem.Department := "Development"
* NewContact.Body := "Sample"
*NewContact.FileAs := "Authorcode"
oItem.Email1Address := _OutlookEmailcontact
oItem.BusinessTelephoneNumber := _OutlookTel
oItem.MobileTelephoneNumber := _OutlookMobile
oItem.MailingAddress := _OutlookEmailcontact
oItem.Subject := "Contact created from X#"
oItem.JobTitle := _OutlookFunction
*oItem.FullName := "Raymond Nathan Warner"
oItem.Save()
RETURN
Raymond, at which line does the error point to? I don't think it is pointing to a line inside the code you posted, or is it?