Use another email on auto-reply, instead of senders email

Hi Community

I've got a demand on a feature in CS, where a automatic reply is sent to another email, than senders email.

More exactly, the incomming mail comes from eMarketeer as noreply@something, and the mail itself contains information about the email, I want to reply to instead.

Is this possible? If yes, how would you proceed, and what do I need to be carefull about? I'm thinking about both the coding part and the mail-server part.

RE: Use another email on auto-reply, instead of senders email

Hi,

Should be possible, but will require CRMScript. You can configure an email filter to find and process your inbound emails. The filter should specify that autoreply should not be sent, and then run a CRMScript which sends an email to the address you found in the body.

I believe you should be able to retrieve the complete raw email like this inside your script:

getVariable("mailBackup");

You can also get the id of the newly inserted message if you want to access it that way (saves you from dealing with email encoding):

getVariable("messageId");

Sending an email in CRMScript is easy using the Email class. If you want your email to be based on a reply template, merged with ticket data, etc then you need to do some more coding using ReplyTemplate, Ticket, etc before setting the email body.

Sverre

Av: Sverre Hjelm 28. sep 2017

RE: Use another email on auto-reply, instead of senders email

Hi Sverre.

Thank you for your answer. That helped me a long way.

Do you know of any currently existing example on how to send an email with a template?

If I understand you correctly, I have to manually setup the email in the code?

Av: Kasper Rosenlund 29. sep 2017

RE: Use another email on auto-reply, instead of senders email

Hi Kasper,

this is something that you (or someone else) needs to code.

If you've set up an e-mail filter that triggers from noreply e-mails and stops default replies you can execute a script that does something like this:

String custEmail = getVariable("customerEmail");

// The ID of your reply template
Integer replyTemplateId = 1;

// The ID of the ticket
Integer ticketId = getVariable("ticketId").toInteger();

// The ID of the customer
Integer custId = getVariable("customerId").toInteger();

Parser p;

ReplyTemplate rt;
rt.load(replyTemplateId);

Ticket t;
t.load(ticketId);
t.toParser(p);

Customer c;
c.load(custId);
c.toParser(p);

// Lang: NO: 0, EN: 1, DE: 2, SE: 3, DK: 4, NL: 5
Integer langId = 1;

String subject = p.parseString(rt.getSubject(langId));
String body = p.parseString(rt.getHtmlBody(langId));

if(custEmail != "")
{
  Email e;
  e.setValue("to", custEmail);
  e.setValue("subject", subject);
  e.setValue("bodyHtml", body);
  e.send();
}

Remember that it needs to be tested, and that this is just an example :)

Av: Simen Mostuen Iversen 29. sep 2017

RE: Use another email on auto-reply, instead of senders email

Hi Simen.

Exactly what I was looking for - a BIG thank you! ;)

Av: Kasper Rosenlund 29. sep 2017

RE: Use another email on auto-reply, instead of senders email

While I'm at it - how do you know the ID of the email templates? When the customer is online, you don't have access to the database :/

Av: Kasper Rosenlund 29. sep 2017

RE: Use another email on auto-reply, instead of senders email

Hi Kasper!

 

It is in the URL, when you open the template

viewReplyTemplate&id=xx

 

Av: Emilija Vilija Treciokaite 29. sep 2017

RE: Use another email on auto-reply, instead of senders email

Thank you for your answer, Emilija :).

Just to keep all my questions in one thread, I have one fundamental question, I can't seem to get working. And I can't find any good tutorial on.

Under Email Filter -> Find Regular Expressions i want to get an email-address from the body, of an incomming email. Here I type realEmail = [a-z]*@[a-z]*.[a-z]*

From this I get the email from the header (since its the first).

I want an email from the body. But whenever I try to specify the regex, like this:

Email:[ ][a-z]*@[a-z]*.[a-z]* or <i>[a-z]*@[a-z]*.[a-z]*</i>

it gives me a blank string. In general, it returns blank if I try anything fance, and I haven't figured out what I allowed to do in this regular expression.

Do you have any idea why this doesnt work?

Av: Kasper Rosenlund 1. okt 2017

RE: Use another email on auto-reply, instead of senders email

Hi again.

Well I got it to work. But I thought the regular expressions was scanning through the HTML, and not the output.

At first I thought I had to take care of alle the tags and brackets, but it turned out I didn't had to.

I'm getting a little confused, because in most of the examples I've founnd in the forum, it seems like people is carefull regarding special characters etc.

Av: Kasper Rosenlund 1. okt 2017