![]() |
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 using the following code in a VB.Net 2005 add-in for Outlook 2003 and on
50% of my workstations I get a Cast Object error. So obviously my approach is wrong: Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup .... Dim objOutlook As Outlook._Application objOutlook = New Outlook.Application() Dim objNS As Outlook._NameSpace = objOutlook.Session objFolder = objNS.GetDefaultFolder(Outlook.OlDefaultFolders.ol FolderSentMail) objFolderItems = objFolder.Items AddHandler objFolderItems.ItemAdd, AddressOf objFolderItemAdded .... End Sub So I believe it's wrong to create a new Outlook session from within Outlook. How else would I do it to avoid the cast error? DG |
#2
|
|||
|
|||
![]()
Answered at http://www.outlookcode.com/threads.a...essageid=24546
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "DG" wrote in message ... I am using the following code in a VB.Net 2005 add-in for Outlook 2003 and on 50% of my workstations I get a Cast Object error. So obviously my approach is wrong: Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup ... Dim objOutlook As Outlook._Application objOutlook = New Outlook.Application() Dim objNS As Outlook._NameSpace = objOutlook.Session objFolder = objNS.GetDefaultFolder(Outlook.OlDefaultFolders.ol FolderSentMail) objFolderItems = objFolder.Items AddHandler objFolderItems.ItemAdd, AddressOf objFolderItemAdded ... End Sub So I believe it's wrong to create a new Outlook session from within Outlook. How else would I do it to avoid the cast error? DG |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
working with System.Net.Mail namespace | rodchar | Outlook - Using Forms | 0 | August 31st 07 03:10 PM |
NameSpace.GetItemFromID() threw an exception | OctopusThu | Add-ins for Outlook | 2 | December 15th 06 06:40 AM |
Outlook View Control : urn.schemas.httpmail namespace | [email protected] | Outlook - Using Forms | 1 | November 30th 06 04:34 PM |
nameSpace.OptionsPagesAdd | Ralf Jansen | Add-ins for Outlook | 2 | May 12th 06 03:01 PM |
GetItemFromID method on a public folder in the namespace | Robert Squire | Outlook and VBA | 1 | February 24th 06 01:31 PM |