![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
I am trying to create a task from a custom form. My code fails on the save
method, generating the following error message. An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in microsoft.visualbasic.dll Additional information: The operation failed. My code is as follows. datDueDate = Now datDueDate = datDueDate.AddDays(7) glbOutlookNewItem = glbOutlookDir.items.add("IPM.Task.CS Request") glbOutlookNewItem.Subject = "Quote Acceptance Test" glbOutlookNewItem.DueDate = datDueDate glbOutlookUP = glbOutlookNewItem.UserProperties glbOutlookUP("Start Date") = datDueDate glbOutlookUP("Due Date") = datDueDate glbOutlookNewItem.save() I have tested that I can create and save a task in the folder manually. Any suggestions would be great. Thanks |
Ads |
#2
|
|||
|
|||
![]()
glbOutlookUP("Start Date") is an object which your code is trying to set
equal to a Date. I can't tell how you've dimensioned your objects that allowed you do that without getting a compiler error, but strong typing is actually your friend. Make sure you have Option Strict and Option Explicit turned on if you're working with COM Interop, to reduce your personal hair-pulling quotient. Try glbOutlookUP("Start Date").Value = datDueDate glbOutlookUP("Due Date").Value = datDueDate "Dave Hogg" u17788@uwe wrote in message news:5a880cf39033b@uwe... I am trying to create a task from a custom form. My code fails on the save method, generating the following error message. An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in microsoft.visualbasic.dll Additional information: The operation failed. My code is as follows. datDueDate = Now datDueDate = datDueDate.AddDays(7) glbOutlookNewItem = glbOutlookDir.items.add("IPM.Task.CS Request") glbOutlookNewItem.Subject = "Quote Acceptance Test" glbOutlookNewItem.DueDate = datDueDate glbOutlookUP = glbOutlookNewItem.UserProperties glbOutlookUP("Start Date") = datDueDate glbOutlookUP("Due Date") = datDueDate glbOutlookNewItem.save() I have tested that I can create and save a task in the folder manually. Any suggestions would be great. Thanks |
#3
|
|||
|
|||
![]()
Dave,
Many thanks for the reply, and I do take your point about the hair pulling. I have tried as you suggest, but it still fails. I have moved the 'Save' to line 3 and it still fails. There seem to be a lot of people who have posted a similar problem out there on various forums. Could this be a .NET bug? Dave Kane [MVP - Outlook] wrote: glbOutlookUP("Start Date") is an object which your code is trying to set equal to a Date. I can't tell how you've dimensioned your objects that allowed you do that without getting a compiler error, but strong typing is actually your friend. Make sure you have Option Strict and Option Explicit turned on if you're working with COM Interop, to reduce your personal hair-pulling quotient. Try glbOutlookUP("Start Date").Value = datDueDate glbOutlookUP("Due Date").Value = datDueDate I am trying to create a task from a custom form. My code fails on the save method, generating the following error message. [quoted text clipped - 23 lines] Any suggestions would be great. Thanks -- Message posted via http://www.officekb.com |
#4
|
|||
|
|||
![]()
Actually, now that I look at your code more closely I think you've got an
earlier type conversion issue. I assume that glbOutlookDir is dimensioned as a MAPIFolder object, and glbOutlookNewItem is presumably dimmed as a TaskItem. The Outlook Items collection is not strongly typed - when you call its Add method in VB.NET you get back an Object. You need to explicitly cast that Object to make it a TaskItem or .NET will raise an exception. If the Imports statement for your Outlook reference looks like this Imports Outlook = Microsoft.Office.Interop.Outlook the line where you instantiate your custom task item should be glbOutlookNewItem = CType(glbOutlookDir.items.add("IPM.Task.CS Request"),Outlook.TaskItem) At that point you should verify the message class of your new item. I hadn't noticed before that you were getting an "unhandled" exception - if you wrap your code in try...catch blocks then you will be able to catch exceptions so you can log the full exception details. That will help you to determine where things start jumping the rails. "Dave Hogg via OfficeKB.com" u17788@uwe wrote in message news:5aa1fe15ccaaf@uwe... Dave, Many thanks for the reply, and I do take your point about the hair pulling. I have tried as you suggest, but it still fails. I have moved the 'Save' to line 3 and it still fails. There seem to be a lot of people who have posted a similar problem out there on various forums. Could this be a .NET bug? Dave Kane [MVP - Outlook] wrote: glbOutlookUP("Start Date") is an object which your code is trying to set equal to a Date. I can't tell how you've dimensioned your objects that allowed you do that without getting a compiler error, but strong typing is actually your friend. Make sure you have Option Strict and Option Explicit turned on if you're working with COM Interop, to reduce your personal hair-pulling quotient. Try glbOutlookUP("Start Date").Value = datDueDate glbOutlookUP("Due Date").Value = datDueDate I am trying to create a task from a custom form. My code fails on the save method, generating the following error message. [quoted text clipped - 23 lines] Any suggestions would be great. Thanks -- Message posted via http://www.officekb.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
custom form | Charlie | Outlook - Using Contacts | 5 | March 8th 06 05:24 PM |
Custom Form Frustration | Frustrated to the MAX! | Outlook - Using Contacts | 4 | February 14th 06 07:35 PM |
Custom form | Melbin | Outlook - Using Forms | 1 | January 24th 06 01:17 PM |
I send an Outlook custom form, but a std. form displays? | Sue Mosher [MVP-Outlook] | Outlook - Using Forms | 0 | January 20th 06 08:41 PM |
Cannot programmatically open custom message in custom form | ms | Outlook - Using Forms | 1 | January 20th 06 04:01 PM |