Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i get information from Outlook?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How do i store email informations like firstname,lastname,
emailid,Attachment from outlook to Ms Access Using VBA?

Example:
column names: Firstname lastname emailid Attach
--------- -------- ------- --------
Steve Waugh stv@aol.com letter.doc


 
Heh... I'm working on the same thing at the moment... add a reference to the outlook library, then:

This should get you started...

Sub DoIt()
Dim olMAPI As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder
Dim colItems As Outlook.Items
Dim objItem As Outlook.MailItem


Set olMAPI = GetObject("", "Outlook.Application").GetNamespace("MAPI")
' Point to the correct folder
Set Folder = olMAPI.Folders("Public Folders").Folders("All Public Folders").Folders("Entertainment")
Set colItems = Folder.Items


For Each objItem In colItems
Debug.Print objItem.Subject
' Grab the data you need here
Next



'Cleanup
Set olMAPI = Nothing
Set Folder = Nothing
Set colItems = Nothing
End Sub
 

Thanks. i have a question.

will this take information like firstname,lastname from Inbox mail?

 
Sort've... I got this working on my inbox:

Sub DoMail()
Dim olMAPI As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder
Dim colItems As Outlook.Items
Dim objEmailItem As Outlook.MailItem


Set olMAPI = GetObject("", "Outlook.Application").GetNamespace("MAPI")
Set Folder = olMAPI.Folders("Mailbox - James Meadlock").Folders("Inbox")

Set colItems = Folder.Items

For Each objEmailItem In colItems
Debug.Print objEmailItem.ReceivedTime
Debug.Print objEmailItem.SenderName
Debug.Print objEmailItem.Subject
Debug.Print objEmailItem.Body
Next

'Cleanup
Set olMAPI = Nothing
Set Folder = Nothing
Set colItems = Nothing
End Sub


Sender Name = "James Meadlock" for things I sent to myself... You could always break that up with code.
 
Thank you very much.

Let me use your program. If i have any question,
i will let you know.

Once again thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top