Link to home
Start Free TrialLog in
Avatar of ICT Department
ICT Department

asked on

Autoforward email and change from to the first emailaddress found in the body.

Hi,

We receive email from one address (let's say ticketsystemA@domain.com) with support tickets, we want those emails to be imported by our other ticket system.
The problem is that all tickets are send from the same user. So when we import, all tickets belong to ticketssystemA.

The first line of the body contains the emailadress of the real user that created the ticket, the rest of the body contains the ticket (and perhaps attachments).

We would like to autoforward the mail to ticketsystemB@domain.com with the sender adress being changed to the address found in the FIRST line of the email.

We have an on-prem Exchange 2016, the ticketsystemB is Always on the same domain as the real ticket creator.


Sorry for my bad English
Avatar of Mahesh
Mahesh
Flag of India image

You cannot change email originator address no matter you forward emails as far as I know
So if A send mail to B and if it auto forwarded to c, then c should see A as sender
U may also redirect emails to C with same effect by using transport rule
Avatar of ICT Department
ICT Department

ASKER

Perhaps not with Exchange, but maybe with powershell it's posible?

With VB (and Outlook) it's possible: https://www.experts-exchange.com/questions/28492433/Extract-email-address-from-body-and-auto-reply.html
You could create a script with EWS and send the email.

I wrote a blog on processing messages in an inbox:

https://blogs.technet.microsoft.com/undocumentedfeatures/2016/07/18/create-an-opt-out-tool-for-exchange-online/
Yes @Aaron, I think that would be perfect... but a bit to complex for me I'm afraid...
Have you tried just setting up a server-side rule on the mailbox 'ticketsystemA@domain.com' to redirect to 'ticketsystemB@domain.com' and save a copy in the original mailbox?  This will retain the original sender when received by ticketsystemB and will also allow tickets to be created in ticketsystemA.
For clarification: I would like to create a PowerShell script that can read incoming email, parse the first line to extract the email address and resend the email with using the email we extracted as the from.

I'm a bit of a powershell noob so I need a bit more help.

I have nothing yet.
A PS script cannot do magic, it is even slightly more difficult to get access to emails, and still requires to have an Outlook profile set up (or use EWS with Exchange).
It's much better to leave PS aside, and run something in Outlook VBA. But that doesn't change that you cannot set arbitrary addresses as sender, unless you allow relying on a specific SMTP server set up for that sole purpose ;-).
Your best choice is to apply the processing when a reply is composed - then you can set the recipient to that real address.
Tnx for the reply!
Can you provide an example which I can modify?
The emails are only internal and the destination also.
Does your ticketing system have an API. That may be an easier route as the others are saying what you are trying to do can not be done. But if you can at least extract the address on the incoming initial email, you can hit the api and update.
I forgot to ask which application creates the reply? If it is your ticket system, you'll have to modify it there.
If we can use Outlook, a event handler for the MailItem.Reply event can parse the (cited) email body and change the address.
No, the ticket system cannot be changed (we are migrating to another ticket system because of this). Only some departments still use this old system hence my question.

I really need somthing (VB or Powershell) that logs into a mailbox, retrieves the emails, changes the from (to the first email found in body) and resends it to another mailbox (same organisation)).
Why resend it? Does the new ticket system take that info on receive, so it has to be correct already at that stage?
If so: Maybe you can set up the new ticket system to monitor a different inbox folder, then use VBA code (optionally together with a rule) to modify the sender info and move to the ticket's inbox (move ≠ send!).
The OLD ticket system can only use one sender emailadress. The new ticketsystem can only read one mailbox and uses the sender adress to know who is the ticket owner.
With normal tickets that gets send to that emailadress that's no problem, but everything that comes out of the old ticket system has thus only on ticket owner…

Trust me, I need what I ask :)
Then the main point of my recommendation is to not require a send with modified addresses, but switch to a move between folders (of different or same accounts) after modifying the "from" part.
This might require using a third account (e.g. ticketSystemA, ticketSystemB and the transfer ticketSystemAB). A sends to AB, and an Outlook with AB and B account (can't do that in Exchange itself) runs VBA code to
  • change FROM according to the first body line
  • change TO to ticketSystemB
  • move from AB inbox to B inbox
The reason for the third account is that you probably cannot set the new ticketing system to check a different inbox folder, and you still need the normal inbox for the "real" communication for tickets.
I can't do anything with the answers :(
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for your answers, I will have a look at the links and tell you guys the outcome :)