Importing mail into .pst

R

Rick

We're migrating users from a proprietary mail system to Exchange. The
original mail is in a SQL database, and we can manipulate it from
Access.

We'd like to import the existing messages into .pst files, so the users
can access them from Outlook once they're on Exchange.

Our mapping options in the import process are limited. Specifically,
we only have one "body" field. In Outlook, this field is treated as
text. Unfortunately, the proprietary system has saved only the HTML
version of multipart messages. When we import this field into Outlook,
we see HTML code.

Clearly, .pst has provisions for holding HTML -- is there no way we can
import it? Will we have to convert the HTML to plaintext?

Is there any way, using CDO or Outlook programming, for example, to
spool this data into a .pst intact -- i.e. so that the HTML is retained?
 
K

Ken Slovak - [MVP - Outlook]

You would have to write the HTML data into .HTMLBody, not .Body. That would
require code, the import wizard won't do that. You could use the Outlook
object model for that. CDO doesn't support HTML directly without using some
hacks.
 
R

Rick

If I work with a .pst file using .addstore, can I populate it with
messages using createitem? I don't have to worry about complicated
business rules -- for example if I have to/from/time/subject/body, is
that all I need to create a message?

Is there functionality in the Outlook object model along the lines of
auto-generate text body found in Exchange?
 
R

Rick

Can you confirm that the Outlook object model is the only way to import
attachments as well?
 
K

Ken Slovak - [MVP - Outlook]

What do you mean "write PST files"? You can create a PST file using AddStore
or add an existing one using that method. You can use standard code to add
items, folders and write to the items.
 
K

Ken Slovak - [MVP - Outlook]

CreateItem will place the items in your default store. Use the Add method of
the Items collection of a MAPIFolder object in the target store to add items
to specific stores or folders. You can write subject and body, you can't
write From or various time fields unless you go down to using Extended MAPI
or Redemption (an Extended MAPI wrapper). In many cases certain fields can't
be written at all even with Extended MAPI.

I have no idea what you mean by a an auto-generated text body.
 
K

Ken Slovak - [MVP - Outlook]

You can't directly import attachments in any API. You need to save them to
the file system and then attach the files. You can attach files using any of
the object models or API's that target Outlook.
 
R

Rick

First, Ken, thanks for all your help. Sounds like we are closer than
ever to a viable plan.

Conceptually, I'm seeing a console app that connects to the database,
retrieves the messages, and goes row-by-row through the recordset,
creating messages with CDO or OOM. The attachments were all extracted
to the file system, using a lookup table. So I could join that into
the recordset and pass the UNC paths as part of the process, and I
gather that as the items are written to the store the attachments would
be read in as well.

Since this is primarily received mail, I'm interested in retaining
"from" details. Am I to understand that this may be lost? Strangely,
isn't this one of the few fields that the import tool does handle?

As for autogenerated text, I was talking about
cdo.message.autogeneratetextbody. In server-side cdo, anyway, this
property tells the system to create a plaintext version of the htmlbody
data. In our case this would be handy, since we only seem to have the
HTML version of the messages in the source system to begin with.

Thanks

Rick
 
K

Ken Slovak - [MVP - Outlook]

After each new item was created you would have to use the file path to the
attachment or attachments for that item to add the attachment to the new
item. Nothing is automatic about it.

oItem.Attachments.Add <filepath> or using it as a function to return an
Attachment object so you can access its properties. That can be done using
the Outlook object model or CDO 1.21 or Redemption or whatever.

Different CDO, there are hundreds of them. CDO 1.21, the client side CDO,
knows nothing about HTML at all. You can force it to work with HTML by doing
weird things with the various RTF* properties, there's an example of that on
the Redemption Web site, but that's about it. Sig Weber might also have
something on HTML and CDO 1.21 at www.cdolive.com/cdo5.htm, but I don't
recall. It's been a while since I did much CDO 1.21 coding.

Using the Outlook object model or CDO you can't set From or related
properties. You can using Extended MAPI or Redemption if you do so before
the item is first saved. After that those properties are read-only, as is
"Sent".
 

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