C#: Check emails and perform SQL operations
Posted on 2014-04-21
I am performing some manual repeated operations in my project and I am planning to make it automatic by creating a tool or program which will remove my extra burden.
I will be receiving emails from client example Check Balance of Clients Account. After receiving such email, I need to run respective SQL query which will provide a set of 10 records as a result. Then I need to export this result in CSV format or excel and save it in my desktop. Then I will reply to client's email which I have received with fixed content in it and will be adding this exported excel doc to this email and will be sending it to the client.
Step 1: Open my email account and check for new email with subject as something like 'Check Balance'
Step 2: Note down the Account Number present in the body of the email
Step 3: Get the corresponding SQL query which is present as text file in my local machine.
Step 4: Run this SQL Query by replacing the Account Number at sufficient locations in SQL Server.
Step 5: Export the resultant SQL output to excel file.
Step 6: Attach this excel file to clients reply email.
Step 7: Copy the body content present in text file present in my machine.
Step 8: Send the email to client.
I do not know if I can achieve above all 8 Steps automatically through C# code but I want to cover as many Steps I can to automatic so that it will save my time.
I will be grateful if experts can help me out here with this...
Thanks in Advance...!!