Sponsored Link

There was an error in this gadget

Sponsored Link

Thursday, November 27, 2008

Accessing Outlook from MS Excel

The post will help you in exporting details like email id, sender's name, date and time of email lying in your Outlook inbox. Similarly, you can modify code to access to export/access other details from Outlook to MS Excel. If your now thinking what will be the use of this code. The answer is very simple, you can take the snapshot of your inbox and know what was the age of particular email at that point of time. Also, you can maintain list of emails from where you receive emails and at times you receive data or table in Outlook which you want to export in MS Excel.
Remember, we are here to provide free MS Excel help and enhance the MS Excel knowledge of all the blog visitors

Sub exportemail1()
'Code is free to use
'Do not remove comments
'for any further help, please visit
http://findsarfaraz.blogspot.com
‘for email me
findsarfaraz@gmail.com
On Error Resume Next
Dim emailcount As Integer
Dim OLF As Outlook.MAPIFolder
Dim ol As New Outlook.Application
'OLF is declared as mapi folder to decide'which folder you want to target
Set OLF = ol.Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
'OLF.Items.Count provide the number of mail present in inbox
emailcount = OLF.Items.Count
'by i=1 we 'are initializing the variable by value 1'else it will throw an error
i = 1
'Here I am using do while - loop to'Browse through all mail
Do While i <= emailcount
Sheet3.Cells(i + 1, 1) = OLF.Items(i).SenderEmailAddress
Sheet3.Cells(i + 1, 2) = OLF.Items(i).SenderName
Sheet3.Cells(i + 1, 3) = OLF.Items(i).SentOn
i = i + 1
Loop
'Like SenderEmailAddress SenderName SentOn'we can use other properties of email to get other 'details
Set OLF = Nothing
Set ol = Nothing
End Sub

Though, this is only post so far. I will try my best to post more and more. Next, I am planning to post basic post on Vlookup, SUMIF and other basic function. For all these update you can subscribe via email.

Outlook to MS Excel Export Example download

We assure you knowledge, not SPAM!

Read more on this article...