MS Outlook Interop CreateItem Task - syntax?
Posted: Sun Oct 30, 2022 2:02 am
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: https://learn.microsoft.com/en-us/offic ... 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.
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: https://learn.microsoft.com/en-us/offic ... 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.