how can I get the information

E

epjames

How can I get the information of the email in the Inbox
folde? e.g. get the sender name, sender email address,
sent date, the content of the email, the attachments if
any.

How do I know the INDEX of the latest email at the Inbox?

set myApp = outlook.application
set myNameSpace = myApp.GetNamespace("MAPI")
set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
set myItem = myFolder.Items(INDEX)

THANKS IN ADVANCE!

epjames
 
G

Guest

If you want the most recent item in the mailbox, you should use the Find
method -- see http://www.outlookcode.com/d/finddate.htm

Outlook properties are accessed as MailItem.propname -- see
http://www.outlookcode.com/d/propsyntax.htm

When in doubt about the name of a property, check the object browser: Press
ALt+F11 to open the VBA environment in Outlook, then press F2. Switch from
<All Libraries> to Outlook to browse all Outlook objects and their
properties, methods, and events. Select any object or member, then press F1
to see its Help topic.


In Outlook 2003, you can use the MailItem.SenderEmailAddress to get the
sender's address. In earlier versions, there is no Outlook property that
returns the sender's email address. You can either use CDO (or Redemption to
avoid security prompts -- http://www.dimastr.com/redemption/) to get the From
address or use Outlook to get the Reply To address. Sample code at
http://www.outlookcode.com/d/code/getsenderaddy.htm

To get the SMTP address from an Exchange sender or recipient, use CDO or
Redemption and the PR_EMAIL (&H39FE001E) MAPI property to obtain the SMTP
address from the AddressEntry object. See
http://www.outlookcode.com/d/code/getsenderaddy.htm#redemption and
http://www.cdolive.com/cdo5.htm#EMailAddressOfSender for examples.
 
E

epjames

Thanks!

I can get the information of the email in the Inbox,
except the sender address and the received date of the
email.

As you mentioned that the sender address should be used
the CDO, how can I know CDO is installed? My outlook
version is 2000 and 2002. I found that there have two dll
(Microsoft CDO for NTS 1.2 Library and Microsoft CDO for
Windows 2000 Library) in the macro editor. If they are
incorrected, where can I get the CDO?

Secondly, I used the ActiveExplorer.Selection to get the
information of the email, such as SenderName, Subject,
Body, Attachments. However, which property is used to
retrieve the recieved date?

epjames
-----Original Message-----
If you want the most recent item in the mailbox, you should use the Find
method -- see http://www.outlookcode.com/d/finddate.htm

Outlook properties are accessed as MailItem.propname -- see
http://www.outlookcode.com/d/propsyntax.htm

When in doubt about the name of a property, check the object browser: Press
ALt+F11 to open the VBA environment in Outlook, then press F2. Switch from
<All Libraries> to Outlook to browse all Outlook objects and their
properties, methods, and events. Select any object or member, then press F1
to see its Help topic.


In Outlook 2003, you can use the
MailItem.SenderEmailAddress to get the
sender's address. In earlier versions, there is no Outlook property that
returns the sender's email address. You can either use CDO (or Redemption to
avoid security prompts --
http://www.dimastr.com/redemption/) to get the From
 
S

Sue Mosher [MVP-Outlook]

Collaboration Data Objects 1.21 is an optional component of Outlook. You can
rerun Outlook or Office setup to install it. CDONTS and CDO for Windows are
different components with a shared (and confusing) name.

When in doubt about property names, check the object browser: Press ALt+F11
to open the VBA environment in Outlook, then press F2. Switch from <All
Libraries> to Outlook to browse all Outlook objects and their properties,
methods, and events. Select any object or member, then press F1 to see its
Help topic.
 
E

epjames

Thanks, Sue.

Everything is running smoothly. However, when I get the
sender's email address from the colleagues, the extracted
address is "/o=ABC Company/ou=First Administrative
Group/cn=Recipients/cn=bernard.tsang", not
(e-mail address removed). We use the Exchange Server
and login the outlook using the domain user. The outlook
version is 2000.

Can I get the normal email address? Can I solve it using
the version as 2002 or 2003?

epjames
 
S

Sue Mosher [MVP-Outlook]

You didn't say earlier that you're using Exchange. To get the SMTP address
from an Exchange sender or recipient, use CDO or Redemption and the PR_EMAIL
(&H39FE001E) MAPI property to obtain the SMTP address from the AddressEntry
object. See http://www.outlookcode.com/d/code/getsenderaddy.htm#redemption
and http://www.cdolive.com/cdo5.htm#EMailAddressOfSender for examples.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
E

epjames

Sorry, Sue.

Actually, the outlook will collect the emails from
colleagues (exchange server) and the out-coming email
address (i.e. (e-mail address removed)). Anyway, thanks for
your help!

epjames
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top