Changing Status of an outlook email to unread

  • Thread starter Thread starter jueberro
  • Start date Start date
J

jueberro

Hello:

I am simply mapping a drive to the exchange servers shared mailbox
directory as the domain admin on the exchange server. Using an Access
Module I wrote VBA code to examine and parse emails in a directory
using a custom class object called Custemail that I parse the email
contents into, and based on examination of the contents , after doing
a bunch of stuff to a CRM database, I then decide which salesrep's
mailbox to copy the mail to. I simply use the
filesystemobject.copyfile functionality to do this:
+++++++++++++++++++++++
Set fso = CreateObject("Scripting.FileSystemObject")

<...Code....>

fso.copyfile CustEmail.fileName, salespersonemailbox &
extractFileNameFromFilePath(CustEmail.fileName)
++++++++++++++++++++++++

Salespersonsmailbox is loaded with the path to that persons inbox.
Everything works fine except the emails show up in the salespersons
inbox as read.. How can I make the file appear to be an "Unread"
email?

Any help would be greatly appreciated.

Thanks,

Joe
 
First off, do you know that using Win32 file system APIs to access the M
drive is not supported by Microsoft?

There's also a danger with moving files from the M drive (not sure if
*copying* is as problematic):

http://support.microsoft.com/kb/281673/en-us

Regardless, you'd need to use any of the messaging APIs (CDO, Outlook Object
Model, etc.) to actually change any of the MAPI properties on those items -
including the read/unread indicator.
 
Eric:

I have never used the MAPI Api.. Can you point me at the technet or
other referneces to get me started with that API. If I have the name
of the ".eml" file, can I simply point at that email by path and name
by passing it to the MAPI API and modify the Unread property?

Any examples??

Thank you VERY much...

Joe
 
Well, MAPI is yet another API compared to CDO or the Outlook Object Model.
Basically, you can't use ANY messaging API (as in any of the above APIs and
others I'm not discussing here) to work with messages in the file system.
You use messaging APIs only in the context of Outlook or Exchange Server.

If you are trying to copy e-mails from one Mailbox to another, why don't you
do so manually using Outlook anyway?
 
Eric:

The environment is one where emails come in from a web site where a
customer requests a catalogue. They are all delivered to a single
mailbox. The emails contain all the relevant data needed to assign
the lead to a Rep. Specifically State and Zip Code. I inherited this
program and the previous programmer developed a custom class in which
he parses the email into object properties defined as elements of the
data. For example the email name is assigned to Custemail.filename.
I currently look at state and zip and compare that to an access table
that holds the Rep/Territory relationship based on State/Zip and I
grab the Reps email address from that rep record and concatenate the M
drive path and that reps email address and use the filesystemobject to
copy the email over to that users inbox and it all works except that
the email shows up as read.

Rather than rewriting all the code I inherited to replace the use of
the Custom Object with the MAPI API to move through the emails, I was
hoping you could tell me how to simply reference the email that I
already have the mailbox name for as well as the specific email
filename for by passing this to a MAPI function call and changing the
Unread property.

I have already probably grabbed enough snippets to get me there but
you seem very knowledgeable and I rather than jumping around I thought
you might be able to point me at a specific code example that shows
the object being instantiated as referencing the appropriate mailbox
and specific email. I haven't found anything like this yet. The
assumption here is that this code will be run as a service on the
server by a user with rights to do everything necessary to the
mailboxes.

Thx,

Joe

P.S. I appreciate your help.
 
Thank You Eric!

It looks like just what I need. I will play with it tonight and let
you know!

Joe
 
Back
Top