none
Unable to read details from the outlook.maiitem when it is gettiong details from outlook.folder RRS feed

  • Question

  • I have wrriten program which will take attcahments from the outlook 2010 folder and placed into the local mechine folder. i am able to read the folders
    and caanot get full details from it like To,CC etc

    dim Objmitem as outlook.mailitem
    dim objfolder as outlook.folder
    dim objAE as outlook.addressentry

    Here i am getting folder details from other function

    objfolder = assign the folder details getting from the other function

    Objmitem = objfolder.items.getfirst

    objAE=Objmitem.sender

    By performing this experssion most of the fileds are showing "Operation Aborted" error message

    using objAE i have to get the detail like SMTP,SenderMilAddress etc to go to next the  level .

    i dont know what could be the exact reason.

    Please help me if any of you faced the sameissue

    Some of the forums suggested it could be the permmission level issue if yes since i am new to this techonology where we have to change the settiings

    Tuesday, March 15, 2016 5:41 AM

Answers

  • >>>By performing this experssion most of the fileds are showing "Operation Aborted" error message 

    using objAE i have to get the detail like SMTP,SenderMilAddress etc to go to next the  level . 

    i dont know what could be the exact reason.<<<

    According to your description, I have made a sample to try to reproduce this issue, unfortunately, I can't. You could refer to below testing code:
    Imports Outlook = Microsoft.Office.Interop.Outlook
    Imports System.Runtime.InteropServices
    
        Sub InboxEmails()
            Dim OutlookApp As Outlook.Application
            Dim inbox As Outlook.Folder = Nothing
    
            OutlookApp = New Outlook.Application
    
            Dim ns As Outlook._NameSpace = OutlookApp.Session
            inbox = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
    
            Dim mailItem As Outlook.MailItem = inbox.Items.GetFirst()
    
            If mailItem IsNot Nothing Then
                If mailItem.SenderEmailType = "EX" Then
                    Console.WriteLine(mailItem.Sender.GetExchangeUser.PrimarySmtpAddress)
    
                ElseIf mailItem.SenderEmailType = "SMTP" Then
                    Console.WriteLine(mailItem.SenderEmailAddress)
                End If
                Console.WriteLine(mailItem.To)
                Console.WriteLine(mailItem.CC)
                Console.WriteLine(mailItem.Subject)
            End If
            'Release COM Objects!
            Marshal.ReleaseComObject(mailItem)
    
            'Release COM Objects!
            If ns IsNot Nothing Then Marshal.ReleaseComObject(ns)
            If inbox IsNot Nothing Then Marshal.ReleaseComObject(inbox)
            If OutlookApp IsNot Nothing Then Marshal.ReleaseComObject(OutlookApp)
        End Sub

    So I suggest that you could run your project on an other machine to check this issue can be reproduced or provide more information about your issue, for example full sample codes, screenshot etc., that will help us reproduce and resolve it.

    Thanks for your understanding.
    • Marked as answer by David_JunFeng Thursday, March 24, 2016 8:44 AM
    Wednesday, March 16, 2016 8:09 AM

All replies

  • Hi yvpardhasaradhi,

    Since your question is more related to Outlook development. We will move your thread to Outlook for developer for better support.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 15, 2016 7:50 AM
  • Do you run secondary threads when dealing with OOM?

    Be aware, you need to use the main thread for calling OOM methods and properties. Outlook can fire exceptions when backgrounds threads are detected. What code exactly do you use?

    Also make sure that all underlying COM objects are released in a timely manner (asap). Use System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. This is particularly important if your add-in attempts to enumerate more than 256 Outlook items in a collection that is stored on a Microsoft Exchange Server. If you do not release these objects in a timely manner, you can reach the limit imposed by Exchange on the maximum number of items opened at any one time. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object. Read more about that in the Systematically Releasing Objects article. 

    Tuesday, March 15, 2016 12:35 PM
  • Also keep in mind that to use GetFirst/GetNext, you must store the Items collection in a dedicated variable instead of using multiple dot notation (Objmitem = objfolder.items.getfirst) and thus getting a brand new Items object on each step.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, March 15, 2016 1:48 PM
  • >>>By performing this experssion most of the fileds are showing "Operation Aborted" error message 

    using objAE i have to get the detail like SMTP,SenderMilAddress etc to go to next the  level . 

    i dont know what could be the exact reason.<<<

    According to your description, I have made a sample to try to reproduce this issue, unfortunately, I can't. You could refer to below testing code:
    Imports Outlook = Microsoft.Office.Interop.Outlook
    Imports System.Runtime.InteropServices
    
        Sub InboxEmails()
            Dim OutlookApp As Outlook.Application
            Dim inbox As Outlook.Folder = Nothing
    
            OutlookApp = New Outlook.Application
    
            Dim ns As Outlook._NameSpace = OutlookApp.Session
            inbox = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
    
            Dim mailItem As Outlook.MailItem = inbox.Items.GetFirst()
    
            If mailItem IsNot Nothing Then
                If mailItem.SenderEmailType = "EX" Then
                    Console.WriteLine(mailItem.Sender.GetExchangeUser.PrimarySmtpAddress)
    
                ElseIf mailItem.SenderEmailType = "SMTP" Then
                    Console.WriteLine(mailItem.SenderEmailAddress)
                End If
                Console.WriteLine(mailItem.To)
                Console.WriteLine(mailItem.CC)
                Console.WriteLine(mailItem.Subject)
            End If
            'Release COM Objects!
            Marshal.ReleaseComObject(mailItem)
    
            'Release COM Objects!
            If ns IsNot Nothing Then Marshal.ReleaseComObject(ns)
            If inbox IsNot Nothing Then Marshal.ReleaseComObject(inbox)
            If OutlookApp IsNot Nothing Then Marshal.ReleaseComObject(OutlookApp)
        End Sub

    So I suggest that you could run your project on an other machine to check this issue can be reproduced or provide more information about your issue, for example full sample codes, screenshot etc., that will help us reproduce and resolve it.

    Thanks for your understanding.
    • Marked as answer by David_JunFeng Thursday, March 24, 2016 8:44 AM
    Wednesday, March 16, 2016 8:09 AM