Solved

how to read outlook emails using vb.net

Posted on 2014-09-26
9
855 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 69

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 69

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
 

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 69

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 69

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 69

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now