How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??

We encourage new members to introduce themselves here. Get to know one another and share your interests.
Post Reply
rn@warner-it.com
Posts: 46
Joined: Mon Mar 04, 2019 4:41 pm

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??

Post 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
User avatar
wriedmann
Posts: 3757
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??

Post 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
newcontact.png (30.54 KiB) Viewed 815 times
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
rn@warner-it.com
Posts: 46
Joined: Mon Mar 04, 2019 4:41 pm

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??

Post 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
User avatar
wriedmann
Posts: 3757
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
rn@warner-it.com
Posts: 46
Joined: Mon Mar 04, 2019 4:41 pm

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??Hi

Post 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
rn@warner-it.com
Posts: 46
Joined: Mon Mar 04, 2019 4:41 pm

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??Hi

Post 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
User avatar
wriedmann
Posts: 3757
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??Hi

Post 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
OutlookContact.zip
(226.05 KiB) Downloaded 117 times
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4922
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??

Post 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?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply