Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to read outlook emails using vb.net

Posted on 2014-09-26
9
Medium Priority
?
1,336 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 2000 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Screencast - Getting to Know the Pipeline
Suggested Courses

879 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