0

For various reason, I need to migration several million emails from one archiving solution to another. The only method of getting the data out of Solution A is by using a proprietary utility to dump individual .MSG files. I've scripted this and it's working fine. To get these .MSG files into Solution B, they need to be added to an exchange mailbox which Solution B then periodically scrapes (hourly). I've scripted this too. Unfortunately I'm having a very particular issue. Each .MSG file dumped out of Solution A has the header information in the body and the original email included as an attachment with all the meta-data preserved. This is completely fine, however my script seems to be dropping a percentage of attachments. What's interesting is that if I run outlook in cached-exchange mode I don't experience this issue (but have a host of other issues when outlook has to sync tens of thousands of emails. When I disable cached-exchange mode, it begins dropping attachments.

The script is fairly lengthy (350 lines) but I've isolated the point at which the attachments drop. For context, what the script does is get a list of .MSG files in a directory tree and then import them one by one until there's 30'000 emails in the inbox. Then it waits for the scrape to run and clear out the inbox before starting again.

The point at which it breaks is between these two lines.

$olMailItem = $NameSpace.OpenSharedItem($msg)
[void]$olMailItem.Move($objNewFolder)

If I print out $olMailItem.Attachments after the first line, it always returns a value of 1. If I print it out after the second line, for the same set of emails it periodically returns a value of 0. Which I interpret as the file is opened correctly, but the process of placing it in exchange is causing some attachments to drop. I can't find anyone on google with the same issue as me. And, this issue does not seem to occur when I enable cached exchange mode (but causes me to deal with a bunch of worse issues). I've trawled the MSDN Outlook developer reference but I can't see anything which is obviously wrong. Hopefully someone here can provide some insight on what could be causing it.

2
  • You're interfacing with Exchange via Outlook? I realise you're quite far down this rabbit hole now, but did you consider using Exchange Web Services to create these items? Then you don't need to worry about Outlook and cahced mode at all. Sep 2, 2014 at 23:43
  • My thinking on that was to abstract the process so I'm not throwing data directly into our production exchange. In theory if anything breaks it will be Outlook rather than exchange. It also makes testing the script that much easier. Outlook also slows the process down so I'm not putting load on exchange.
    – AB87
    Sep 3, 2014 at 0:54

0

You must log in to answer this question.

Browse other questions tagged .