Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending an email on keyword in capture file

Status
Not open for further replies.

kgornek

Technical User
Mar 11, 2004
50
US
I've played with this a little but I'm just not familiar enough with ASPECT to make it work. I have a constant capture file running from an output from a 5ESS switch. Is there a way that I can have an email sent whenever a specific keyword scrolls across the screen? This is a XP OS computer which is on a LAN with Outlook 2003 installed. Outlook can be made to be running in the background full time if need be.

I read the previous post on this, but it wasn't very specific and I don't think it applied to my situation.
 
I don't have a script on my samples page that does quite this, but there should be a mail script or two that would handle that portion of the task. To key off a certain string, you could use a when target command in your script that called a procedure to send the email. Would you be sending just a generic email, or would there need to be some information passed to the email that would be different each time, such as data from the screen?

 
What it captures may be different but the email will be pretty generic. I would just like the keyword of the the capture to maybe be in the subject or body of the message.

I've looked at the some of the mail scripts and they are a bit confusing to me. I wouldn't need a log in or password for the email program and could have it already opened to make it easier if need be.
 
Hmm, looks like I don't have one of the scripts online that I thought I did, which shows how to bring up Outlook's new message dialog, fill it out, and send the message. I'll see if I can find it later tonight and post it online.

 
Great! I sure do appreciate the help.
 
I copied and pasted this into a script file and just keep getting a error of "Outlook Express not running, script exiting!" I am using regular Outlook so unfortunately I don't think this will work for me.
 
You might just have to make a few modifications...

Code:
winactivate "Inbox - Outlook Express"
to
Code:
if winactivate "Inbox - Microsoft Outlook"

and a couple of occurances of
Code:
winactivate "Inbox - Outlook Express"
to
Code:
winactivate "Inbox - Microsoft Outlook"


 
Ok, I will try that out. But how do I make the script find what I want it to find in the actual capture file?
 
You can use strfind if you are searching the capture file (will need to go line by line), or you could use the when target command to catch the string when it comes across initially and not even bother with the capture file.

 
Well the capture file constantly runs and restarts every night at Midnight with the current date as it's file name. So I'm not sure if it can search a capture file that is currently in use/open. So the "When" command might be a better solution for this application. (?)

I changed the Outlook Express to Microsoft Outlook and now get the error "Exported message could not be located in c:\tempmail.txt, script exiting!"

Now I have your file that you gave me the link to, and pasted it into a script file within Procomm, but I'm not sure what lines I need to edit to make it work. For example...

string sLine ;Data read from exported email/capture file

Am I supposed to edit this line? I know string is a command but have no idea what sline is as there is no help topic on it.
 
Basically you want to edit out a lot of the if statements and reorganize what is left. Remember that this script is pulled out from a customer project and is just there currently to give some insight on how to manually navigate an Outlook window via the script. I'll try to clean up this up for future reference sometime soon (think it's on my to-do list).

 
Any updates knob? I cannot seem to get this to work and have made all the changes suggested in this thread. I keep getting the generic error of "Microsoft Outlook not running, script exiting!
 
I found a script on here that opens Outlook and places the prompt in the subject box that works great. I just need that script to activate with a specific keyword and send an email to an address.
 
Ok, I'm making progress. Just two issues to overcome; getting the script to keep running after it finds the keyword(s), and wishing I could part of the text of the actual capture file into the email so it wouldn't be so generic. Any suggestions?

proc main
waitfor "*C" forever matchcase
call Outlook
endproc

proc Outlook
integer iTask, iWindow, iStatus = 0
string sTaskName

if firsttask iTask ;Search list of tasks for outlook.exe
taskname iTask sTaskName
if strnicmp sTaskName "outlook.exe" 11 ;Search for Outlook process
taskwin iTask iWindow
winactivate iWindow ;Bring Outlook to foreground
launch_message() ;Run procedure to open new message
iStatus = 1 ;Set flag indicating Outlook was found
endif
while nexttask iTask
taskname iTask sTaskName
if strnicmp sTaskName "outlook.exe" 11
taskwin iTask iWindow
winactivate iWindow
launch_message()
iStatus = 1
endif
endwhile
endif
if iStatus == 0 ;Outlook not active
run "c:\program files\microsoft office\office\outlook.exe"
pause 5
launch_message()
endif
endproc

proc launch_message
pause 3
sendkey CTRLSHIFT 'M' ;Open new message
pause 1
sendkeystr "kgornek"
pause 1
sendkey ALT 'J' ;Move to subject line
pause 1
sendkeystr "5ESS Alarm"
sendkey 0x09
sendkeystr "A Critical Alarm has been detected. This is an automated test email for the 5ESS."
sendkey ALT 'S'
endproc
 
You can make the script run forever by wrapping the code in proc main within an endless loop like this:

proc main
while 1
waitfor "*C" forever matchcase
call Outlook
endwhile
endproc

For the second task, usually I would use the rget command to read the text as it came in from the port, which would prevent it from appearing on-screen. That would presume the *C you are searching for is the beginning of the string you are looking to catch.

 
I'm a little unclear of where exactly to put the rget command and how to take the data it receives and places it in the email. Can you explain a bit further please?
 
The rget command would be after the waitfor command and would grab the remainder of the line sent by the remote system. That would be placed in a string variable specified by the rget command and you could use the contents of that string in your email.

 
Am I only allowed to get one line? I place the rget command under the waitfor command and nothing happened. plus I'm not sure how I get that data into the actual email? Sorry but I am lost here. I read help on the rget command but still don't understand how to get more information, where it is stored, and how to get that information into the email I have sending out. ??

Here is what I have now with these errors...

Error C102: Missing operand
Error C163: Invalid string variable

proc Monitor
while 1
waitfor "op:clk" forever matchcase
rget RAW
call Outlook
endwhile
endproc

proc Outlook
integer iTask, iWindow, iStatus = 0
string sTaskName

if firsttask iTask ;Search list of tasks for outlook.exe
taskname iTask sTaskName
if strnicmp sTaskName "outlook.exe" 11 ;Search for Outlook process
taskwin iTask iWindow
winactivate iWindow ;Bring Outlook to foreground
pause 2
launch_message() ;Run procedure to open new message
iStatus = 1 ;Set flag indicating Outlook was found
endif
while nexttask iTask
taskname iTask sTaskName
if strnicmp sTaskName "outlook.exe" 11
taskwin iTask iWindow
winactivate iWindow
pause 2
launch_message()
iStatus = 1
endif
endwhile
endif
if iStatus == 0 ;Outlook not active
run "c:\program files\microsoft office\office11\outlook.exe" maximized
pause 5
launch_message()
endif
endproc

proc launch_message
pause 3
sendkey CTRL 'N' ;Open new message
pause 1
sendkeystr "G., Kenneth;W, William E."
pause 1
sendkey ALT 'J' ;Move to subject line
pause 1
sendkeystr "Critical PITB 5ESS Alarm - Automated"
sendkey 0x09
sendkeystr "A Critical alarm has been detected. This is an automated email for the Pittsburgh 5ESS."
sendkey ALT 'S'
endproc
 
Can you post an example of the data you want to capture? Is it usually more than one line?

As for the compile error, it is because you do not have a string variable defined for the rget command to place the string into. You'll need to define a variable in the procedure or globally (global might be better since you'll need to access it in the procedure that does the Outlook operations) and then use it in the rget command.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top