Email in from multiple mailboxes – easier than you think

automator-logo

Prerequisites if you like to try it:

  • You already have an ITPR demo account or a production account. If not, you can easily request one with demo data.
  • You already signed up for a techwork automator demo account. If not, goto the registration blog post.
  • Create a test mail account at for instance gmail.com

Business case:

Each ITRP account has its own email address. It is always the id of your organisation’s ITRP account plus @itrp.com. You can find your id when you open the “Account Overview” section in the settings console. Note: There is no email address for your ITRP demo environment.

Basically each ITRP account is associated with one mailbox. Which is fine, because as you might know you can have multiple ITRP accounts for different purposes and all people, organisations etc. are then defined in the directory account.

However, some companies operate with just one ITRP account and they want to read emails from multiple mailboxes. For instance people are used to write emails to “firewall-requests@organization.com” if they need any changes on the firewall, or “facility.maintenance@organization.com” if light bulbs need to be changed and they still use “SAP-development@organization.com” to log new requirements for SAP.

The automator provides the capability to do that in a smart way.

1st – you can define multiple mail boxes:

inboxes

2nd – attach an email profile to a package:

Because of that capability you don’t need to read the mailTo address. In my case the package automatically reads only from the sap-development inbox.

SAP_dev_profile

 The automator package

The package checks if the person exists in ITRP and creates a RFC for the Service Instance “SAP Basis Europe Development (D45)”.

[code language=”javascript”]
$mailFrom = mail.from[0];
$mailFromAddr = $mailFrom.address;
$mailFromAddr = ‘beatrice.baldwin@widget.com’;

$filter = ‘primary_email=’ + $mailFromAddr;
$person = fetchFilter(‘people’, $filter, ‘directory’)[0];

if ($person) {
create(‘requests’, {
subject: mail.subject, note: mail.text,
category: ‘rfc’,
requested_by_id: $person.id,
service_instance_id: $SAP_Basis_SI
});
}
else {
log(‘reject mail: ‘,$mailFromAddr);
}
[/code]

 

The code with comments

[code language=”javascript”]
$mailFrom = mail.from[0];
$mailFromAddr = $mailFrom.address;
$mailFromAddr = ‘beatrice.baldwin@widget.com’;
//simulate beatrice as sender

$filter = ‘primary_email=’ + $mailFromAddr;
$person = fetchFilter(‘people’, $filter, ‘directory’)[0];
//look in the directory account for beatrice in that case
log(‘$person.id :’, $person.id);

//if the person (Beatrice) exists create a RFC and fill all
//required fields in ITRP
if ($person) {
create(‘requests’, {
subject: mail.subject, note: mail.text,
category: ‘rfc’,
requested_by_id: $person.id,
service_instance_id: $SAP_Basis_SI
});
}
else {
//if the person (Beatrice) does not exist just write into the log
log(‘reject mail: ‘,$mailFromAddr);
}
[/code]

 

Interesting to note

One of the latest updates of the automator is the capability that you can write JSON syntax. Instead of writing code like:

[code language=”javascript”]
$newSAPrequest.subject = mail.subject;
$newSAPrequest.note = mail.text;
$newSAPrequest.category = ‘rfc’;
$newSAPrequest.requested_by_id = $person.id;
$newSAPrequest.service_instance_id = $SAP_Basis_SI

create(‘requests’,$newSAPrequest);
[/code]

you have the option to use JSON syntax :

[code language=”javascript”]
create(‘requests’, {
subject: mail.subject, note: mail.text,
category: ‘rfc’,
requested_by_id: $person.id,
service_instance_id: $SAP_Basis_SI
});
[/code]

It makes it just a bit easier.

k.konwalin@techwork.at

Leave a Reply