Click here to Skip to main content
14,740,854 members
Articles » Web Development » ASP.NET » General
Posted 15 Mar 2006


33 bookmarked

Extracting mails and attachments from outlook 2003 in

Rate me:
Please Sign up or sign in to vote.
2.67/5 (9 votes)
15 Mar 2006
Extracting mails



Here, I am putting some sample code for extractng mails and attachments from Outlook 2003 using VB.NET.

The program will extarct the mail from selected folder in Outlook 2003.

For this, first add a reference to Outlook.

****write this code for getting the mails ***************

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
olfolder = objOL.GetNamespace("MAPI").PickFolder
myItems = olfolder.Items

Dim i As Integer
For x = 1 To myItems.Count myItems.Item(x).SenderEmailAddress)
    messagebox.showmyItems.Item(x).Body) myItems.Item(x).to)
    messagebox.showmyItems.Item(x).ReceivedByName) myItems.Item(x).ReceivedOnBehalfOfName)
    messagebox.showmyItems.Item(x).CC) myItems.Item(x).ReceivedTime)
Next x

***********for getting attachments use this code******************

Dim Atmt As Outlook.Attachment

For Each Atmt In Item.Attachments
    filename = "C:\Email Attachments\" + Atmt.FileName
Next Atmt

Try it out .. and let me know if there is any problem.



This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
India India
No Biography provided

Comments and Discussions

QuestionSuperb Pin
James Ryan12-Jun-12 9:30
MemberJames Ryan12-Jun-12 9:30 
Generalhi I am facing a problem with the code you have displayed can u please help me Pin
Member 784194914-Apr-11 7:24
MemberMember 784194914-Apr-11 7:24 
GeneralRe: hi I am facing a problem with the code you have displayed can u please help me Pin
Member 784194914-Apr-11 7:58
MemberMember 784194914-Apr-11 7:58 
I got reply thank u soooooooooooooooo much... ur post saved me today.

on some help can i store the message box information in a txt ...if so how????
GeneralMy vote of 1 Pin
Dave Kreskowiak23-Dec-09 9:28
mveDave Kreskowiak23-Dec-09 9:28 
Generalreading attachments with different file extensions Pin
salon19-Mar-07 21:10
Membersalon19-Mar-07 21:10 
QuestionHow can I test about "Extracting mails and attachments from outlook 2003 in " Pin
hoplq27-Sep-06 1:57
Memberhoplq27-Sep-06 1:57 
GeneralEmbedded email Pin
BobSnowden19-Sep-06 7:02
MemberBobSnowden19-Sep-06 7:02 
QuestionHow to compare your approach with Simple MAPI as in this article? Pin
tank2096-Apr-06 13:36
Membertank2096-Apr-06 13:36 
Questionhow to import a mail Pin
Chris_kun28-Mar-06 18:51
MemberChris_kun28-Mar-06 18:51 
AnswerRe: how to import a mail Pin
tank2096-Apr-06 13:38
Membertank2096-Apr-06 13:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.