![]() |
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
|
|||
|
|||
![]()
Receiving message in Outlook when call interop from vb.net and trying to
read/load emails from inbox to windows form into datagridview. Message is: The add-in "c\program files\postx\trusted messaging client for outlook\..." could not be installed or loaded. This message occurs at different times, never on the same email. Usually after it loads over 150 emails. We think it is related to COM performance, thus put in System.Threading.Thread.Sleep(100), this seems to work, but slow to load emails. Any input would be helpful. Here is the basic code. Dim oAppm As Microsoft.Office.Interop.Outlook.Application = New Microsoft.Office.Interop.Outlook.Application Dim oInboxm As Microsoft.Office.Interop.Outlook.MAPIFolder Dim oItemsm As Microsoft.Office.Interop.Outlook.Items Dim oNSm As Microsoft.Office.Interop.Outlook.NameSpace = oAppm.GetNamespace("MAPI") oInboxm = oNSm.GetDefaultFolder(Microsoft.Office.Interop.Out look.OlDefaultFolders.olFolderInbox) oItemsm = oInboxm.Items For i As Integer = oItemsm.Count To 1 Step -1 'Test to make sure item is a mail item and not a meeting request. sClassComp = oItemsm.Item(i).messageclass Select Case sClassComp Case "IPM.Note", "IPM.Note.Rules.ReplyTemplate.Microsoft", "IPM.Note.Secure" Me.DataGridView1.Rows.Add() Dim oMsgm As Microsoft.Office.Interop.Outlook.MailItem oMsgm = TryCast(oItemsm.Item(i), Microsoft.Office.Interop.Outlook.MailItem) iCellCounter = 0 Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter).Value = oMsgm.SenderName Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter + 1).Value = oMsgm.Subject Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter + 2).Value = oMsgm.ReceivedTime Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter + 3).Value = oMsgm.ConversationIndex Pause() iRowCounter += 1 Case Else End Select Next i |
Ads |
#2
|
|||
|
|||
![]()
That error is a startup load error for a COM addin. The only way to tell
what's failing in the load is to do managed code troubleshooting and look at the Fusion logs. See http://blogs.msdn.com/vsod/archive/2...-failures.aspx for information on that. Usually if you run out of RPC channels it's against Exchange server, and it usually happens at around 250 passes in a loop. That's due to managed code not releasing objects in the garbage collector soon enough, your pause may help by allowing the GC to run. A better approach is to explicitly release all of your objects by setting them to Nothing, and you may even have to call Marshal.ReleaseComObject() on them and then call to GC.Collect() each pass in the loop. Also, never use compound dot operators such as this: sClassComp = oItemsm.Item(i).messageclass That creates an internal object for the oItemsm.Item(i) object that can't be explicitly released. Use instead something like this: Dim item As object = oItemsm.Item(i) sClassComp = item.MessageClass That allows you to explicitly release "item". However, the error when you run into a limit on RPC channels is usually a lack of resources or memory error, not a load error. Another thing is if this code is running in an Outlook COM addin never, ever use New to create an Outlook.Application object. Instead, use the Application object passed to you in Startup() for VSTO addins or in OnConnection() in shared addins. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "DP" wrote in message ... Receiving message in Outlook when call interop from vb.net and trying to read/load emails from inbox to windows form into datagridview. Message is: The add-in "c\program files\postx\trusted messaging client for outlook\..." could not be installed or loaded. This message occurs at different times, never on the same email. Usually after it loads over 150 emails. We think it is related to COM performance, thus put in System.Threading.Thread.Sleep(100), this seems to work, but slow to load emails. Any input would be helpful. Here is the basic code. Dim oAppm As Microsoft.Office.Interop.Outlook.Application = New Microsoft.Office.Interop.Outlook.Application Dim oInboxm As Microsoft.Office.Interop.Outlook.MAPIFolder Dim oItemsm As Microsoft.Office.Interop.Outlook.Items Dim oNSm As Microsoft.Office.Interop.Outlook.NameSpace = oAppm.GetNamespace("MAPI") oInboxm = oNSm.GetDefaultFolder(Microsoft.Office.Interop.Out look.OlDefaultFolders.olFolderInbox) oItemsm = oInboxm.Items For i As Integer = oItemsm.Count To 1 Step -1 'Test to make sure item is a mail item and not a meeting request. sClassComp = oItemsm.Item(i).messageclass Select Case sClassComp Case "IPM.Note", "IPM.Note.Rules.ReplyTemplate.Microsoft", "IPM.Note.Secure" Me.DataGridView1.Rows.Add() Dim oMsgm As Microsoft.Office.Interop.Outlook.MailItem oMsgm = TryCast(oItemsm.Item(i), Microsoft.Office.Interop.Outlook.MailItem) iCellCounter = 0 Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter).Value = oMsgm.SenderName Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter + 1).Value = oMsgm.Subject Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter + 2).Value = oMsgm.ReceivedTime Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter + 3).Value = oMsgm.ConversationIndex Pause() iRowCounter += 1 Case Else End Select Next i |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
search remote calendars with Microsoft.Office.Interop.Outlook 11 | entvex | Outlook - General Queries | 1 | January 28th 09 03:03 PM |
Hot to get propetyInfo of Microsoft.Office.Interop.Outlook.MailIte | Jongmin | Outlook - Using Forms | 1 | October 16th 08 03:47 PM |
Unable to cast object of type 'System.__ComObject' to type 'Microsoft.Office.Interop.Outlook.ApplicationClass' | John Yovas | Add-ins for Outlook | 2 | September 12th 08 05:23 PM |
How to get Microsoft.Office.Interop.Outlook.TaskItem from the IUnknown (C#) | Godandag | Add-ins for Outlook | 5 | April 5th 07 10:39 AM |
Msdn help for Microsoft.Office.Interop.Outlook members | DavidE | Add-ins for Outlook | 0 | August 9th 06 08:45 AM |