A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Want e-mail addresses from items in my inbox



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 23rd 09, 09:09 PM posted to microsoft.public.outlook.program_vba
Stanley
external usenet poster
 
Posts: 7
Default Want e-mail addresses from items in my inbox

I have the following code:
Private Sub myOlApp_InboxItems()
Dim myOlApp As Outlook.Application
Dim myfolder As Outlook.MAPIFolder
Dim myitems As Items
Dim mynamespace As NameSpace
Dim n As Integer
Set myOlApp = CreateObject("Outlook.Application")
Set mynamespace = myOlApp.GetNamespace("MAPI")
Set myfolder = mynamespace.GetDefaultFolder(olFolderInbox)
Set myitems = myfolder.Items
MsgBox myitems.Count
n = 1
MsgBox myitems(n) 'this gives me the subject of the 1st e-mail in my inbox
End Sub
From this I can loop and see the subject of each e-mail in my inbox. What I
would like to see is the e-mail address of the sender and the date it was
sent.
Any ideas how I can code this?
Thanks,
Stanley
Ads
  #2  
Old December 24th 09, 03:40 PM posted to microsoft.public.outlook.program_vba
Stanley
external usenet poster
 
Posts: 7
Default Want e-mail addresses from items in my inbox

I did this and its works fine except I can't get the SenderEmailAddress (it
is not there).
I can get "ReceivedTime" and "SenderName".
I am using Outlook 2002.
Any ideas?
Thanks,
Stanley

"Ken Slovak - [MVP - Outlook]" wrote:

Instantiate an Outlook.MailItem from that myitems(n). Then read any
properties you want from the MailItem such as ReceivedTime or
SenderEmailAddress.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Stanley" wrote in message
...
I have the following code:
Private Sub myOlApp_InboxItems()
Dim myOlApp As Outlook.Application
Dim myfolder As Outlook.MAPIFolder
Dim myitems As Items
Dim mynamespace As NameSpace
Dim n As Integer
Set myOlApp = CreateObject("Outlook.Application")
Set mynamespace = myOlApp.GetNamespace("MAPI")
Set myfolder = mynamespace.GetDefaultFolder(olFolderInbox)
Set myitems = myfolder.Items
MsgBox myitems.Count
n = 1
MsgBox myitems(n) 'this gives me the subject of the 1st e-mail in my
inbox
End Sub
From this I can loop and see the subject of each e-mail in my inbox. What
I
would like to see is the e-mail address of the sender and the date it was
sent.
Any ideas how I can code this?
Thanks,
Stanley


.

  #3  
Old December 24th 09, 06:38 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Want e-mail addresses from items in my inbox

SenderEmailAddress was added in Outlook 2003. A hack workaround would be to
create a reply and get the address from that:

Dim oReply As Outlook.MailItem
Set oReply = oMail.Reply
strAddress = oReply.Recipients.Item(1).Address
oReply.Close olDiscard

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Stanley" wrote in message
...
I did this and its works fine except I can't get the SenderEmailAddress (it
is not there).
I can get "ReceivedTime" and "SenderName".
I am using Outlook 2002.
Any ideas?
Thanks,
Stanley

  #4  
Old December 29th 09, 08:30 PM posted to microsoft.public.outlook.program_vba
Stanley
external usenet poster
 
Posts: 7
Default Want e-mail addresses from items in my inbox

This worked out OK. except when I tried to get an email sender from our own
email server i got /O=ZONI GROUP/OU=FIRST
ADMINISTRATIVEGROUP/CN=RECIPIENTS/CN=STANLEY.
I tried this is Outlook 2003 and and got the same result using
SenderEMailAddress.
Any ideas,
Thanks,
Stanley

"Ken Slovak - [MVP - Outlook]" wrote:

SenderEmailAddress was added in Outlook 2003. A hack workaround would be to
create a reply and get the address from that:

Dim oReply As Outlook.MailItem
Set oReply = oMail.Reply
strAddress = oReply.Recipients.Item(1).Address
oReply.Close olDiscard

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Stanley" wrote in message
...
I did this and its works fine except I can't get the SenderEmailAddress (it
is not there).
I can get "ReceivedTime" and "SenderName".
I am using Outlook 2002.
Any ideas?
Thanks,
Stanley

.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
add multiple addresses from inbox to contacts tee_sk Outlook - Using Contacts 1 May 19th 09 10:37 AM
EXTRACTING EMAIL ADDRESSES FROM INBOX Gaby Huut Bay Outlook - Using Contacts 1 June 26th 08 07:57 PM
Two e-mail addresses in Inbox Allan Outlook Express 3 December 19th 07 11:52 PM
Inbox displays new mail message but nothing new appears in Inbox 4sh Outlook - Installation 0 April 5th 07 02:24 PM
Inbox, Sent Items & Outbox in Deleted Items in Outlook 2003 & OWA with Exchange splounx Outlook - General Queries 1 February 17th 06 02:22 AM


All times are GMT +1. The time now is 11:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.