I need to search a string in a text file and send a mail incase the string is found

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pallavi dhanuka
    New Member
    • Jan 2011
    • 2

    I need to search a string in a text file and send a mail incase the string is found

    I need to search a string in a text file(to be more specific its a log file) and send a mail incase the string is found .
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Why you want to send an Email after searching the file, why not when the event is logged?

    Regards
    Dheeraj Joshi

    Comment

    • pallavi dhanuka
      New Member
      • Jan 2011
      • 2

      #3
      ya actually i want to send an mail when the event is logged, stating that event. Its like if the evnt is critical then I will have to send an email stating the entire event and what error occured.

      Comment

      • Dheeraj Joshi
        Recognized Expert Top Contributor
        • Jul 2009
        • 1129

        #4
        Check this out.

        Regards
        Dheeraj Joshi

        Comment

        • nathj
          Recognized Expert Contributor
          • May 2007
          • 937

          #5
          It looks like the Java Mail classes are the way forward and they are fairly easy to use too. If you get stuck with them post back - I'll keep an eye on this thread as I have some experience using these classes.

          If you do need to check a file for a string then take a look here. I haven't written or reviewed this code but at first glance the basic principles seems to be spot on.

          Hope this is helpful and remember to shout if you get stuck.
          nathj

          Comment

          • abhinavgarg1988
            New Member
            • Jan 2012
            • 1

            #6
            I also have the same requirement as above, could anyone please give methis code

            Comment

            Working...