Solved

how to read outlook emails using vb.net

Posted on 2014-09-26
9
915 Views
Last Modified: 2014-09-30
Hi, I need to read the emails from outlook. The code is giving me an error

        Dim objOL As Outlook.Application
        Dim objNS As Outlook.NameSpace
        Dim objFolder As Outlook.Folders
        Dim Item As Object
        'Dim myItems As Outlook.Items
        Dim x As Int16

        objOL = New Outlook.Application()
        objNS = objOL.GetNamespace("MAPI")

        Dim olfolder As Outlook.MAPIFolder
        If direction = "IN" Then
            olfolder = objOL.GetNamespace("Mapi").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        Else
            olfolder = objOL.GetNamespace("Mapi").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail)
        End If

        myItems = olfolder.Items

It bombs in the ofolder.items giving an error :

Interface not registered (Exception from HRESULT: 0x80040155)

I appreciate your help experts. Thanks
0
Comment
Question by:fmichail
  • 5
  • 4
9 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40347551
I prefer not use automation to read Excel. I use http://www.limilabs.com/mail
0
 

Author Comment

by:fmichail
ID: 40347702
Eric Moreau,
Thanks for the response, however, I am restricted to interface the application with outlook. Can mail.dll interface with outlook? Like list emails from outlook / send email through outlook / open and view outlook / retrieve the outlook currently selected email?

In fact I have little understanding of how emails are retreived, and saved in general. however, the component looks encouraging  if it interfaces with outlook.

Please reply. Thanks
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 40347749
mail.dll is like connecting to your mail server to retrieve them, read, delete

if you would like to send email, you better just use the .Net framework system.net.mail (http://systemnetmail.com/)
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:fmichail
ID: 40348161
Thanks again Eric, the application is targeting a company which uses outlook for emails. Can mail.dll connect to where the emails of the users are (I do not know where outlook retrieves them from), and retrieve these emails even while outlook is working ... in other words, is there any setting (or coding) to tell mail.dll how retrieve the outlook emails for the current user... Sorry Eric, I do not know how outlook works... Please reply. when the mail.dll sends an email, will it show in the outlook sent folder... I hope you know what I mean.. Thanks in advance.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40348545
mail.dll will not do that. It has to be configured with the credentials of the user to connect to the Exchange server. Also, it won't put emails in the sent items.

You are probably better to stick with automation then!
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40348547
0
 

Author Comment

by:fmichail
ID: 40352790
Hi Eric,
Yes I tried the same code, but unfortunately, I got the same error in the same spot. by the way, is it the same to reference MS outlook object library (as in your like) OR to reference MS.Office.Interop.outlook?.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40352922
yes
0
 

Author Closing Comment

by:fmichail
ID: 40353410
Although my problem is not fixed, however, Eric directed to a better way of handling Emails, that I will definitely consider. Thanks Eric
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question