Want e-mail addresses from items in my inbox

  • Thread starter Thread starter Stanley
  • Start date Start date
Status
Not open for further replies.
S

Stanley

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
 
Instantiate an Outlook.MailItem from that myitems(n). Then read any

properties you want from the MailItem such as ReceivedTime or

SenderEmailAddress.

"Stanley" <Stanley> wrote in message

news:46C43858-9DDF-4104-9553-C65979BBFFC5@microsoft.com...
> 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
 
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
wrote:


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

> >

>

> "Stanley" <Stanley> wrote in message
> news:46C43858-9DDF-4104-9553-C65979BBFFC5@microsoft.com...
> >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


> .
>
 
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

"Stanley" <Stanley> wrote in message

news:278206EA-53E3-4B92-94C5-A89A6346008B@microsoft.com...
> 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
>
 
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
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

> >

>

> "Stanley" <Stanley> wrote in message
> news:278206EA-53E3-4B92-94C5-A89A6346008B@microsoft.com...
> >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
> >

> .
>
 
To convert a Exchange DN (distinguished name) type email address into an

SMTP address you would need to use a lower level API such as CDO 1.21 or

Redemption (www.dimastr.com/redemption) or Extended MAPI (C++ or Delphi

only). Depending on which API you use and what version of Outlook and

whether or not cached mode is being used you then can retrieve the MAPI

property for the SMTP address.

See http://www.outlookcode.com/threads.aspx?forumid=5&messageid=12791 for

some additional information and code samples on this.

"Stanley" <Stanley> wrote in message

news:643BE6CF-645B-47EE-A812-33ADE2C2095A@microsoft.com...
> 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
>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Victor_50 Outlook 365 Extract all mail addresses and names from a pst file to csv. Using Outlook 3
O Extracting all mail addresses from all folders Using Outlook 10
cimbian Harvesting email addresses from mail folders Using Outlook 1
Diane Poremsky Make the Address Book show only e-mail addresses, not fax numbers Using Outlook 0
P Removing expired e-mail addresses Using Outlook 2
A E-Mail Merge to All E-Mail Addresses on One BCM Contact BCM (Business Contact Manager) 1
G VBA Interfering with Email Addresses in Mail Merge? Outlook VBA and Custom Forms 2
D Outlook 2003 - A program is trying to access e-mail addresses Outlook VBA and Custom Forms 5
R Single Quotes sometimes around e-mail addresses Using Outlook 7
S Mail not showing in created folder Using Outlook 3
P Messages stuck in Outbox - actually a Comcast mail client issue Using Outlook 3
P Windows 11 tries to open New Outlook when the user clicks on the mail icon on a news article Using Outlook 2
Rupert Dragwater Mail won't show as read Using Outlook 2
M Outlook 365 Amending code so macro runs within current new mail window Outlook VBA and Custom Forms 0
O Junk E-mail Options disabled(?) Using Outlook 3
E Replying to a plain text e-mail with HTML Using Outlook 2
P Limited Support for 3rd Party Mail in new Outlook? Using Outlook 1
T Exchange Server - Mail Delay Stamping Exchange Server Administration 0
L Error when exporting Sent Mail to Excel Outlook VBA and Custom Forms 6
X Run macro automatically when a mail appears in the sent folder Using Outlook 5
K How can I delete an e-mail from Outlook Using Outlook 1
L Help: set flag for sent mail to check if received an answer Outlook VBA and Custom Forms 2
A Macro Mail Alert Using Outlook 4
e_a_g_l_e_p_i MY Outlook 2021 changed the format of the shortcuts for mail, calendar etc. Using Outlook 10
Z Outlook 365 Automatically assign categories to incoming mail in a shared folder Round Robin Outlook VBA and Custom Forms 1
W Outlook 365 I am getting the "Either there is no default mail client" error when I try to send an email on excel Office 365 Using Outlook 1
D Gmail mail is being delivered to a different email inbox in Outlook App 2021 Using Outlook 2
P What is your strategy for dealing with SPAM and Junk Mail? Using Outlook 1
C Code to move mail with certain attachment name? Does Not work Outlook VBA and Custom Forms 3
T 1:1 Datatransfer from incoming mail body to customs form body Outlook VBA and Custom Forms 0
O Mail rule issue Using Outlook 3
A manual rule sends mail to wrong folder Using Outlook 5
Aussie Outlook 365 Rule runs manually but returns the error code "an unexpected error has occurred" when incoming mail arrives Using Outlook 1
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2
Witzker Outlook 2019 Macro to answer a mail with attachments Outlook VBA and Custom Forms 2
D Outlook 2003 Mail Fails Using Outlook 1
Cathy Rhone Mail merge error message Using Outlook 1
R Sent emails show iCloud mail account not the alias Using Outlook 2
D Advanced e-Mail search on from/to contact group only searches for first 20 contacts in group Using Outlook 0
P Print attachments automatically and move the mail to an existing folder called "Ted" Outlook VBA and Custom Forms 4
P Importing other e-mail accounts into Outlook Using Outlook 1
lcarpay Stay in the mail folder pane after ctrl-1 Using Outlook 1
O Exchange Sync period only (e.g. last years mail) Using Outlook 0
F Excel VBA to move mails for outlook 365 on secondary mail account Outlook VBA and Custom Forms 1
M Convertor for Outlook Express Mail Store (.dbx) to Outlook Mail Store (.pst) Using Outlook 0
T vba extract data from msg file as attachment file of mail message Outlook VBA and Custom Forms 1
J E-mail held in Outbox while Minimized Using Outlook 3
G Forward email body to other mail list directly from Exchange server Exchange Server Administration 1
T Outlook creates a copie of every mail I send Using Outlook.com accounts in Outlook 4
N Please advise code received new mail Using Outlook 0

Similar threads

Back
Top