Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

MS Outlook Interop CreateItem Task - syntax? 30 Oct 2022 03:02 #24287

  • jonhn
  • jonhn's Avatar
  • Topic Author


  • Posts: 72
  • Hoping someone has a snippet they can post... I'm stuck on creating a new Outlook task - it was very easy in the VO/OLE I was using, and probably still is in X# with Interop but I've now gone slightly cross-eyed trying; so here I am again.

    I'm declaring the Interop full class names in my code so as to avoid "USING" which was interfering with my other converted VO.Classes... It works for all the Word, Excel and other Outlook interop I've done, and this must be close...

    Problem: I'm not sure if I've declared oTask as the right thing, and not sure how to finally instantiate it. Maybe I also need a Microsoft.Office.Interop.Outlook.TaskItemClass?

    METHOD PBOutlook()
    LOCAL oOutlook AS Microsoft.Office.Interop.Outlook.ApplicationClass
    LOCAL oTask AS Microsoft.Office.Interop.Outlook.TaskItem

    oOutLook := Microsoft.Office.Interop.Outlook.ApplicationClass{}

    oTask:= oOutlook:CreateItem(oOutlook.OlItemType.olTaskItem) <---- this fails ( 'oOutlook' IS a variable but IS used like a type)

    Here's one C# solution
    task = (Outlook.TaskItem)OutlookApp.CreateItem(Outlook.OlItemType.olTaskItem);

    If I look here: learn.microsoft.com/en-us/office/vba/api...plication.createitem, I can't get the OIItemType to identify as a TaskItem.

    I've tried a lot of different ideas - I think it is Outlook.OlItemType.olTaskItem that I have wrong - if anyone has an idea that would be great!

    Thank you.

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

    MS Outlook Interop CreateItem Task - syntax? 30 Oct 2022 07:57 #24289

    • Chris
    • Chris's Avatar


  • Posts: 3759
  • Hi John,

    I think that's what you're looking for:

    oTask := oOutlook:CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olTaskItem)

    the "OlItemType" is an enumeration, which a type containing many constants, it's not a member of the Application class that you were trying to use it at in your code snippet.
    XSharp Development Team
    chris(at)xsharp.eu

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

    MS Outlook Interop CreateItem Task - syntax? 30 Oct 2022 09:56 #24294

    • jonhn
    • jonhn's Avatar
    • Topic Author


  • Posts: 72
  • Thank you Chris,
    Yes, that is exactly the one I was looking for. Happy Sunday!

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

    • Page:
    • 1