Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Reading Email from Excel

Hello!
I have successfuly done, with your help, a macro that sends e-mail from
excel, via outlook (very cool stuff by the way).
I have a new task now. I want to import the text, subject and sender of an
e-mail received in outlook to a data base I keep in Excel.
Does someone know how to do this?
Best regards and thanks in advance,
Albert C
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Reading Email from Excel

On Jul 25, 11:06 pm, Albert wrote:
Hello!
I have successfuly done, with your help, a macro that sends e-mail from
excel, via outlook (very cool stuff by the way).
I have a new task now. I want to import the text, subject and sender of an
e-mail received in outlook to a data base I keep in Excel.
Does someone know how to do this?
Best regards and thanks in advance,
Albert C


I assume you're been to Ron de Bruin's site, which is where I got most
of what's below.

This code will get email from a specified folder and move the email to
the Deleted Items once processed. Remove that section if you don't
want it, but this will check every email in the folder and create
duplicates if you're adding to a folder. You could add a check on date
or something too so that it only works on email from a specified
period.

Sub GetFromInbox()

Dim strEmployeeEmail As String
Dim strArrivalTime As String
Dim strSubject As String
Dim strBody As String

'late binding to Outlook
Dim olApp As Object
Set olApp = CreateObject("Outlook.Application")

Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim DelFldr As MAPIFolder
Dim olMail As Variant

Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)

Set Fldr = olNs.Folders("mailbox - Your MB name").Folders("email
test")
Set DelFldr = olNs.Folders("mailbox - Your MB
Name").Folders("Deleted items")

For Each olMail In Fldr.items

'get the values needed from the email
ArrivalTime = olMail.ReceivedTime
EmployeeEmail = olMail.SenderName
strBody = olMail.Body
strSubject = olMail.Subject

'----------------
'Add Code Here to place the variables where you want them
in your WB

'-------------------

'move the email to Deleted Items
olMail.Move DelFldr

Next olMail

Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing


End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Reading Email from Excel

Thank you much sir... Just what I needed.

" wrote:

On Jul 25, 11:06 pm, Albert wrote:
Hello!
I have successfuly done, with your help, a macro that sends e-mail from
excel, via outlook (very cool stuff by the way).
I have a new task now. I want to import the text, subject and sender of an
e-mail received in outlook to a data base I keep in Excel.
Does someone know how to do this?
Best regards and thanks in advance,
Albert C


I assume you're been to Ron de Bruin's site, which is where I got most
of what's below.

This code will get email from a specified folder and move the email to
the Deleted Items once processed. Remove that section if you don't
want it, but this will check every email in the folder and create
duplicates if you're adding to a folder. You could add a check on date
or something too so that it only works on email from a specified
period.

Sub GetFromInbox()

Dim strEmployeeEmail As String
Dim strArrivalTime As String
Dim strSubject As String
Dim strBody As String

'late binding to Outlook
Dim olApp As Object
Set olApp = CreateObject("Outlook.Application")

Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim DelFldr As MAPIFolder
Dim olMail As Variant

Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)

Set Fldr = olNs.Folders("mailbox - Your MB name").Folders("email
test")
Set DelFldr = olNs.Folders("mailbox - Your MB
Name").Folders("Deleted items")

For Each olMail In Fldr.items

'get the values needed from the email
ArrivalTime = olMail.ReceivedTime
EmployeeEmail = olMail.SenderName
strBody = olMail.Body
strSubject = olMail.Subject

'----------------
'Add Code Here to place the variables where you want them
in your WB

'-------------------

'move the email to Deleted Items
olMail.Move DelFldr

Next olMail

Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing


End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
send email to each customer email in excel sheet. -keevill- Excel Discussion (Misc queries) 3 July 17th 08 02:33 PM
reading email geedubb Excel Discussion (Misc queries) 3 May 24th 08 01:12 AM
Email addresses in Excel need to format for mass email Boomer Excel Worksheet Functions 1 June 9th 06 01:46 PM
Email editor closes when forwarding Excel-embedded email Bambina Setting up and Configuration of Excel 0 March 16th 06 10:45 PM
working on excel document in email saved changes in email not in . butter Excel Discussion (Misc queries) 2 February 20th 06 09:25 AM


All times are GMT +1. The time now is 02:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"