Reviewing properties

  • Thread starter Thread starter JT
  • Start date Start date
J

JT

I have a macro that processes attachments to e-mails. The
macro copies the attachment to a new folder where it
compiles the data in a new workbook. The e-mail subject
line contains the office code for the data in the e-mail.

The Outlook properties also contain the office code for
the person sending the e-mail.

I would like the macro to compare both office codes and
make sure they are the same before processing the
attachment.

Is there a way to review the Outlook properties (to get
the office code) without actually opening the e-mail?

If not, I could use some help programming opening the e-
mail and reviewing the properties.

Thanks for the help.....
 
What exactly do you mean when you say the office code is in the "Outlook
properties"?

You can get a handle to the e-mail without opening it by using the
Outlook.Application.ActiveExplorer.Selection object, which will retrieve the
selected e-mail in the folder. If only one e-mail item is selected, this
will give you the MailItem object:

Dim objMsg As Outlook.MailItem

If Application.ActiveExplorer.Selection.Count = 1 Then
If Application.ActiveExplorer.Selection.Item(1).Class = olmail Then
Set objMsg = Application.ActiveExplorer.Selection.Item(1)
End If
End If

Then use can access all the Properties of the objMsg object (such as
Subject). If you need to open the message, call objMsg.Display.
 
Back
Top