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 ?? 06 Apr 2019 16:04 #8232

  • rn@warner-it.com's Avatar


  • Topic Author


  • Posts: 46
  • 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 ?? 06 Apr 2019 17:40 #8239

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2300
  • 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 ?? 06 Apr 2019 18:46 #8241

  • rn@warner-it.com's Avatar


  • Topic Author


  • Posts: 46
  • 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 ?? 06 Apr 2019 20:59 #8243

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2300
  • 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 06 Apr 2019 22:58 #8247

  • rn@warner-it.com's Avatar


  • Topic Author


  • Posts: 46
  • 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 06 Apr 2019 22:58 #8248

  • rn@warner-it.com's Avatar


  • Topic Author


  • Posts: 46
  • 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 07 Apr 2019 07:13 #8254

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2300
  • 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 ?? 07 Apr 2019 14:04 #8263

  • Chris's Avatar

  • Chris


  • Posts: 2038
  • 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