fbpx
Welcome, Guest
Username: Password: Remember me
Welcome to the XSharp forum!

Tell us and our members who you are, what you like and why you became a member of this site.
We welcome all new members and hope to see you around a lot!
  • Page:
  • 1

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

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ?? 8 months 1 week ago #8232

  rn@warner-it.com's Avatar Topic Author Offline Posts: 27
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

Please Log in or Create an account to join the conversation.

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ?? 8 months 1 week ago #8239

  wriedmann's Avatar wriedmann Away Posts: 1913
Hi Raymond,

your code has ever worked?

On my machine, the following code creates a contact:
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:

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy

www.riedmann.it - docs.xsharp.it
Attachments:

Please Log in or Create an account to join the conversation.

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ?? 8 months 1 week ago #8241

  rn@warner-it.com's Avatar Topic Author Offline Posts: 27
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

Please Log in or Create an account to join the conversation.

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ?? 8 months 1 week ago #8243

  wriedmann's Avatar wriedmann Away Posts: 1913
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

www.riedmann.it - docs.xsharp.it

Please Log in or Create an account to join the conversation.

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??Hi 8 months 1 week ago #8247

  rn@warner-it.com's Avatar Topic Author Offline Posts: 27
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

Please Log in or Create an account to join the conversation.

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??Hi 8 months 1 week ago #8248

  rn@warner-it.com's Avatar Topic Author Offline Posts: 27
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

Please Log in or Create an account to join the conversation.

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ??Hi 8 months 1 week ago #8254

  wriedmann's Avatar wriedmann Away Posts: 1913
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

File Attachment:

File Name: OutlookContact.zip
File Size:226 KB
Wolfgang Riedmann
Meran, South Tyrol, Italy

www.riedmann.it - docs.xsharp.it
Attachments:

Please Log in or Create an account to join the conversation.

How to create a Contact in Outlook 32 Bit I tried Can anyone help please ?? 8 months 1 week ago #8263

  Chris's Avatar Chris Offline Posts: 1526

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?
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Page:
  • 1