Network Automation Software We are currently migrating this forum
over to our HelpSystems domain. Please
post all new threads in our new
HelpSystems Community Portal.
Post to the HelpSystems Forum
You are not currently logged on. You must be logged on in order to post. Log on
Or Create a new account
AutoMate Discussion
Decrease font size
Increase font size
Topic Title: React to email received event?
Topic Summary: anyone have a slick way to do this?
Created On: 10/29/2014 04:59 PM
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Leonard Amabile, on Wednesday, November 19, 2014 2:34 PM

Answer:
John,

The trigger that you are requesting is really a combination of a schedule trigger and the Get Email or Exchange actions. That's how an email trigger would work. It would poll an account based on an interval and then once the secondary condition is met, it will execute the task. I have a few tasks I run internally that accomplish this on a daily basis. I have provided a few samples below using the Exchange action. The Exchange filters are very powerful. If you have a schedule interval of 10 minutes, the Exchange filter can include emails that are newer than the last 10 minutes plus whatever other filters you require.
 10/29/2014 04:59 PM
User is offline View Users Profile Print this message

Author Icon
JohnScott
Artisan (200-499)

Posts: 231
Joined: 10/27/2010

One sort of event that I have been surprised not to find available as a trigger/condition in BPA is responding to receiving an email. For instance, we have vendors who send an email to alert us that a file is ready to be transferred. Ideally, we'd have a workflow waiting to receive that notification email, and once it has arrived, the workflow would retrieve the file and process it. This is so common, that I'm surprised not to find this scenario addressed in the Help file or the forums.

With the actions available, I can imagine writing a workflow that would read the headers from the Inbox of a mail account, and when the count increases, look for a signal string in the subject or body, and then move the message to a folder within the mailbox. I've made one or two attempts to do this in BPA7 and BPA8, and been stymied. My first pokes at it in BPA10 look promising.

But I'm lazy, and I wonder if someone out there already has good fundtional code for this that they are willing to share.

Thanks,
John

Edited: 12/20/2014 at 04:22 PM by AutoMate Discussion Moderator
 10/30/2014 03:17 PM
User is offline View Users Profile Print this message

Author Icon
Valentineo McGowan
HelpSystems

Posts: 766
Joined: 09/03/2013

Hello John,

Actually you're on the right path. You would have to create a 'custom trigger' so to speak.
Create a Schedule Condition that executes every minute, 5 minutes, hour, etc.
Add logic in the beginning of task that would 'only' download a specific email based on a filtered criteria. If no email retrieved, ELSE, end task.
If an email is retrieved then steps run to execute the file that was transferred.

You could also simply just use a schedule condition that executes every minute, 5 minutes, hour, etc. to then first check if the file exists using an Advanced FTP action 'If file exists' after logging on. If not found, log off, end task.

Note The 'If file exists' under FTP Advanced is only in v8 and higher.

-------------------------

Valentineo McGowan | Technical Consultant
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1 213.738.6966 | F: +1.213.738.7665
 10/30/2014 03:38 PM
User is offline View Users Profile Print this message

Author Icon
JohnScott
Artisan (200-499)

Posts: 231
Joined: 10/27/2010

Thanks for that encouragement, Valentineo!

If anyone has done this and is willing to share, I'd still be interested in example code.

John
 11/02/2014 01:06 PM
User is offline View Users Profile Print this message

Author Icon
Gijsberth de Ruiter
Artisan (200-499)

Posts: 455
Joined: 03/30/2005

Hi John,
I'm happy to help you on the way, but can you give some more info on the task so that the example will make more sense.

for instance:
- how do you recognize the email: by sender, by header, or ...? And is this text constant, or only partly constant?
- Where is the file to download? Is it an attachment, or??
- Is the downloaded file an .exe or something like that, or does it ned another program to execute?

I will be traveling a few days, but answer again on return.

Thanks
Gijs

-------------------------
I am an A-Team Member
 11/03/2014 09:34 AM
User is offline View Users Profile Print this message

Author Icon
JohnScott
Artisan (200-499)

Posts: 231
Joined: 10/27/2010

Gijs, thank you for your kind offer and willingness. I am specifically NOT asking anyone to write any example code for me. I am only asking for a share of any existing code that someone else is already using successfully.

The particular example in our world where I have wanted to use a technique like this is one where I would recognize the trigger message by its Subject string. The Subject is mostly constant except for a date that changes. There is no attachment that I care about; it is a notification that a file has been placed on an SFTP server and is available for me to go pick up.

Because I haven't yet invested the effort to write the kind of inbox polling workflow Valentineo and I discussed, I currently handle this situation by polling the SFTP server over a certain span of hours each week when I expect the file to become available. This works OK, but doesn't robustly handle holidays and other variations that life throws our way.

My secondary purpose of this thread was to gauge the demand for a a trigger/condition like this. If it incited a stronger response, perhaps our friends at NA would take the hint and add it to the feature set in the next version.

John
 11/19/2014 01:22 PM
User is offline View Users Profile Print this message

Author Icon
JerryFeldman
Apprentice (20-49)

Posts: 50
Joined: 06/02/2011

Hi John,

I do something similar to what you want to do.

I receive an email with an attachement that needs to be unzipped and processed. I created an VBAproject in Outlook as follows,

Public Sub Ach2Disk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\Procs\ABF_ACH\"

For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
Set objAtt = Nothing
Next
Shell "C:\Program Files (x86)\AutoMate 9\AMTask.exe C:\Procs\ABF_ACH\abfACH.aml", vbNormalFocus
End Sub

The you set up a rule in Outlook that runs this piece of code (run a script) when the email arrives.

You can also create a batch file that is called from a rule, does any file moving/deletes/etc and then launched the AM task.

Hope that gives you some ideas.

Jerry
 11/19/2014 01:41 PM
User is offline View Users Profile Print this message

Author Icon
JohnScott
Artisan (200-499)

Posts: 231
Joined: 10/27/2010

Jerry, thank you for sharing your solution to this situation. I will keep it in mind.

Correct me if I'm wrong, but it sounds like your approach would require that you have a computer logged in with your email addressee, and with Outlook open. Or do you set it up as a server-side rule so that Exchange runs it even without a running instance of Outlook?

John
 11/19/2014 02:22 PM
User is offline View Users Profile Print this message

Author Icon
Leonard Amabile
HelpSystems

Posts: 5454
Joined: 05/15/2007

Answer Answer
John,

The trigger that you are requesting is really a combination of a schedule trigger and the Get Email or Exchange actions. That's how an email trigger would work. It would poll an account based on an interval and then once the secondary condition is met, it will execute the task. I have a few tasks I run internally that accomplish this on a daily basis. I have provided a few samples below using the Exchange action. The Exchange filters are very powerful. If you have a schedule interval of 10 minutes, the Exchange filter can include emails that are newer than the last 10 minutes plus whatever other filters you require.


Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)


-------------------------

Leonard Amabile | Director, Cross Platform Support
AutoMate | InterMapper | Skybot | Divisions of HelpSystems
T: +1.213.738.1700 | F: +1.213.738.7665


Edited: 11/19/2014 at 03:00 PM by Leonard Amabile
 11/19/2014 02:34 PM
User is offline View Users Profile Print this message

Author Icon
JohnScott
Artisan (200-499)

Posts: 231
Joined: 10/27/2010

Thank you, Leonard, for sharing these snippets.

John
 11/21/2014 06:40 AM
User is offline View Users Profile Print this message

Author Icon
BenjaminKorper
Artisan (200-499)

Posts: 231
Joined: 06/18/2009

Hi John,

We've implemented this in several ways at several customers. Unfortunately i'm not allowed to share the code itself.
What i can tell you is that the most advanced (dynamic) implementation we've done does this:
Workflow 1:
Trigger: Scheduled, every 5 minutes
Task: Retrieve and parse all e-mail. Use the sender adress (example@google.com) of the e-mail to create a file in a specific folder (C:\example\go.txt). The file that is written to disk may contain certain parameters that are parsed from the e-mail. We also save all attachments to a folder (C:\Attachments\example\attachementfile.name)
Delete the e-mail.

Workflow 2,3,4,etc.
Trigger: File trigger connected to c:\example\go.txt
Task 1: Parse the parameters, if present, from the triggerfile and set as shared VAR.
Task 2: Can be anything

Note: The delete the e-mail part is very important, there is currently a bug in BPA/AM that makes the e-mail actions (especially delete) very slow when you have 1000+ items in the inbox.

@ Leonard: May I assume there is a feature request in the DB for an e-mail trigger?

Regards,

Benjamin

-------------------------

 11/21/2014 03:58 PM
User is offline View Users Profile Print this message

Author Icon
Ricardo Castaneda
HelpSystems

Posts: 3424
Joined: 01/11/2008

Hi Benjamin,

I can confirm that we do have a feature request in our DB for an "Email Trigger" (#F479).

-------------------------

Ricardo Castaneda | Principal Support Analyst
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1.213.738.1700
 12/03/2014 01:14 PM
User is offline View Users Profile Print this message

Author Icon
JerryFeldman
Apprentice (20-49)

Posts: 50
Joined: 06/02/2011

Hi John,

I think it is true that my Outlook needs to be running.
Statistics
18258 users are registered to the AutoMate Discussion forum.
There are currently 0 users logged in.
The most users ever online was 5551 on 01/08/2018 at 11:11 AM.
There are currently 2120 guests browsing this forum, which makes a total of 2120 users using this forum.

FuseTalk Enterprise Edition v4.0 - © 1999-2020 FuseTalk Inc. All rights reserved.

Sitemap Network Automation Software Blog