scythetleppo Posted May 24, 2006 Share Posted May 24, 2006 (edited) expandcollapse popup#include<file.au3> Global $oMyRet[2];email Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc");email Global $ReadArray[2], $found = 0 #NoTrayIcon $File = "example" $Ext = ".txt" $body ="" ;SplashTextOn ('Intro', Archiving example.txt via email!', 200, 75) ;Sleep (5000) ;SplashOff () RunWait (@ComSpec & " /c dir c:\*" & $Ext & " /s /b > c:\outputfile.txt", "", @SW_HIDE) _FileReadToArray ("c:\outputfile.txt", $ReadArray) For $i = 1 To $ReadArray[0] If StringInStr($ReadArray[$i], $File & $Ext) Then ;MsgBox (0, "Found File", $ReadArray[$i]) $file = fileopen($ReadArray[$i], 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file for reading!.") Exit EndIf ; Read in lines of text until the EOF is reached While $i < 101 $line = FileReadLine($file) If @error = -1 Then ExitLoop ;MsgBox(0, "Line read:", $line) $body = $body & $line & "<br />" $i = $i + 1 Wend FileClose($file) $found = 1 EndIf Next If $found = 0 Then MsgBox (0, "Finished", "No Files Found!") FileDelete ("c:\outputfile.txt") $rc = _INetSmtpMailCom('smtp.xxxxxx.com', "From Desktop", "address@blah.com", "address2@blah.com", "Your Information", $body, "", "","", "loginaccount", "password") If @error then msgbox(0,"Error sending message!","Error code:" & @error & " Description:" & $rc) EndIf Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "") $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Cc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x] SetError(1) return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Sent the Message $objEmail.Send if @error then SetError(2) return $oMyRet[1] EndIf EndFunc;==>_INetSmtpMailCom ; ; ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description,3) ;ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc;==>MyErrFunc exit Func do_nuthin() Send ("") EndFunc What this is supposed to do: -locate file anywhere on drive.always the same filename and extension, always only one, always text. -email the contents to myself What it does: -I don't know about 1st part -emails me a blank email, when I know the file is there I have 2 comps on same connection, when I try it from my other computer or this one, it emails me correctly! But when I had my friend test it, I get sent a blank email. Edited May 24, 2006 by scythetleppo Link to comment Share on other sites More sharing options...
scythetleppo Posted May 24, 2006 Author Share Posted May 24, 2006 Hi, Through some debugging my friend says it's finding more than just the one file, other files with different names! [but same extensions] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now