Share via


Powershell script to read email contents using Web Exchange Service

Question

Wednesday, January 28, 2015 4:51 AM | 1 vote

Hello All,

In our environment, we have a feature where a mail sent to a mailbox automatically creates a ticket in a ticketing tool.
There is a powershell script which reads the mail in the mailbox and creates a file based on the contents in the mail body including the attachments.

We have a new requirement where in when a user X sends a mail to user Y and Y forwards the mail to the mailbox, the ticket created in the tool should have details of X in the requester fields on the ticket. As per current code, the details captured are of Y. To achieve this a outlook macro has been written based on which the mail is received in following format.

**************************************************************************************************

From: [email protected]

Sent: Tuesday, January 06, 2015 3:27 PM
To: [email protected]

Subject: FW: Mail Title

[email protected] 1/6/2015 2:16:54 PM  Mail Title

From: [email protected]

Sent: Tuesday, January 06, 2015 2:17 PM
To: [email protected]

Subject: Mail Title

Hello,

I have issue with my printer which is in Building 1, 3<sup>rd</sup> floor.

*************************************************************************************************

When a mail is received by the mailbox, I need to check the mail body and find if there is an entry like below.

[email protected] 1/6/2015 2:16:54 PM <Mail Title>

Expected Output is:
[email protected] to be mapped to the "From" in Header
1/6/2015 2:16:54 PM to be mapped to "Sent" in Header
<Mail Title> to be mapped to "Subject" in Header

Please let me know how I can achieve this.

Thanks.

All replies (2)

Wednesday, January 28, 2015 1:42 PM ✅Answered

Glen Scales has an some excellent examples and tutorials on his blog:

http://gsexdev.blogspot.com/2012/01/ews-managed-api-and-powershell-how-to.html

[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "


Wednesday, January 28, 2015 2:30 PM | 1 vote

First of all,due toallof the "where" and "Where in" and "who's on first?"  itis very difficult to find your question.

Without trying to write a recipe try to just ask a simple, one sentence, question.  By simplifying the request you migh see how to resolve the issue.

Hint:  What is the relationship between a forwarded mail message and the original?

¯\(ツ)_/¯