Powershell – How to take an eml file and place it in the inbox for journaling, without sending the email

archivelyncpowershell

I have an archiving system that reads both envelope and legacy journaling messages in an Exchange 2010 environment.

The journaling target is simply a mailbox that receives a copy of every SMTP message, and there is a 3rd party application that scans, imports, and removes the messages form the journaling mailbox (standard stuff as far as journaling goes)

I now want to integrate Lync into this solution

According to both my tests and this blog, the output will be an EML file and will have the correct SMTP 2822 headers:

Date: Thu, 11 Dec 2014 17:30:37 GMT
MIME-Version: 1.0
Content-Type: multipart/mixed;
    boundary="MIME_Boundary"
From: chris@hp.com
To: brian@hp.com
Session-Id: 7f428701-9876-41a8-b205-ec459a3001ee;dc4575464;32D39476574310618E6AE8F59B02B3FC
Subject: Conversation between ....

--MIME_Boundary
Content-Transfer-Encoding: base64
Content-Type: text/html;
    charset="utf-8"

PGdddddGJvZHdatag== mode data here....
--MIME_Boundary--

Question

How can I import this email message into the journal mailbox (by script)?

What I've tried

The bonehead approach is to send the archive txt to each of the respective users. Presumably I can do this by copying to the IIS directory for sending email (pickup folder I believe). However this sends all the users an email when this is complete, which is not what I desire

The approach that I prefer is essentially this:

Telnet to port 25
MAIL FROM: doesnt@matter.com
RCPT TO: SMTP_Of_JournalMailbox@matter.com
DATA
<PASTE THE CONTENTS OF THE EMAIL HERE>
.

This will result in the message being sent only to the journal mailbox, and not to the recipients, and the data will be added to the archive.

The Powershell method of sending an email seems to alter the "to", but what I want to do is make the "TO" in the Envelope and the "TO" in the message body different.

Best Answer

in Exchange 2007 +, thus you are on 2010, the best way to achieve your goal is with EWS.

For that part, you will need programming skill, but there is a simple answer for you;

How to: Import items by using EWS in Exchange

There is a how-to I wrote some time ago to do it in C/C++;

How-to: Exchange Web Service with API coding in native C/C++

Last link, how to do it with curl in linux;

Quick and Dirty UNIX Shell Scripting with EWS

Related Topic