Results 1 to 5 of 5

Thread: Reading Outlook 2007 .msg file with VB.Net 2010

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2011
    Posts
    38

    Reading Outlook 2007 .msg file with VB.Net 2010

    I am using the following code to get information from Outlook .msg files (created by Save As from
    Outlook), such as .SenderName, etc., as shown in the code. This works on all but two of many
    .msg files.

    The problem is that it does not work on .msg files that are actually saved meeting notices.
    I get the following error:
    Unable to cast COM object of type 'System.__ComObject' to interface type
    'Microsoft.Office.Interop.Outlook.MailItem'. This operation failed because the QueryInterface
    call on the COM component for the interface with IID '{00063034-0000-0000-C000-000000000046}' failed
    due to the following error: No such interface supported (Exception from HRESULT: 0x80004002
    (E_NOINTERFACE))

    Then I have to exit Outlook to clear the error.

    I have searched with Google and found another person who had this problem, but no solution was given.

    Any ideas of how to process the meeting notices?

    Thanks.

    Code:
      Dim oOutL As New Outlook.Application
      Dim oMail As Outlook.MailItem
      Dim email As Outlook.MailItem
    
          oMail = CType(oOutL.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItem)
    
          Dim MsgFileName As String
          MsgFileName = ChangeToSharedPath(gsDatabaseNames(iThisDatabase))
    
          email = oMail.Application.Session.OpenSharedItem(MsgFileName)
    
          With email
            AllOfMSGPreserveCase = .SenderName & .SentOn & .To & .CC & .BCC & .Subject & .Body
            AllOfMSGPreserveCase &= AttachmentsList
          End With
    Last edited by MLarsB; Aug 3rd, 2012 at 03:05 PM. Reason: Added Dim oOutL As New Outlook.Application

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width