Thursday, 2 May 2019

Send mail without using port explicitly

There was a time when I was in the mid of automation. Everything from a to z I just wanted to automate. This was one of my personal items which I thought to have myself the mail delivered in case of failure.

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <ie.au3>
#include <file.au3>
#include <FileConstants.au3>


$file = @DesktopDir&"\mahabharat.txt"
FileOpen($file, 0)

For $i = 1 to _FileCountLines($file)
    $line = FileReadLine($file, $i)

 Local $hDownload = InetGet($line, @DesktopDir & "\" & StringRight($line,6) , $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
 Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

ConsoleWrite($line&@CRLF)
Next
FileClose($file)

To download all the episodes of Mahabharat

There was a time when I became a dying hard fan of Mahabharat, I waned to watch each and every episode of BR Chopra's. I had a notepad file that had all the links. Now I just needed to download them one by one. So here's what I wrote:-

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <ie.au3>
#include <file.au3>
#include <FileConstants.au3>


$file = @DesktopDir&"\mahabharat.txt"
FileOpen($file, 0)

For $i = 1 to _FileCountLines($file)
    $line = FileReadLine($file, $i)

 Local $hDownload = InetGet($line, @DesktopDir & "\" & StringRight($line,6) , $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
 Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

ConsoleWrite($line&@CRLF)
Next
FileClose($file)