tag:blogger.com,1999:blog-68558246062731575672023-11-15T23:46:59.826+05:45I Write in PythonPython is FunAnonymoushttp://www.blogger.com/profile/06648542260836304057noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-6855824606273157567.post-33710306797190907012014-08-17T21:36:00.005+05:452014-08-17T21:36:52.375+05:45Fetching Email on Top of your Gmail Account<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "Trebuchet MS",sans-serif;">This is my first post writing code in this blog. In this post, I am going to to share a couple of lines of code, very simple yet powerful enough to fetch the Email at the top of your G Mail Inbox. The code has been pasted in Pastebin and the link to the code is: <a href="http://pastebin.com/5zDkYx1g">http://pastebin.com/5zDkYx1g</a></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">Below is given the code. You are allowed to try it out and even do something extra with this piece of code: </span><br />
<br />
<div style="text-align: center;">
<br /></div>
<div class="de1" style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;"><span class="kw1">import</span> <span class="kw3">imaplib</span></span></div>
<div class="de2" style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">mailserver<span class="sy0">=</span><span class="kw3">imaplib</span>.<span class="me1">IMAP4_SSL</span><span class="br0">(</span><span class="st0">"imap.gmail.com"</span><span class="sy0">,</span><span class="nu0">993</span><span class="br0">)</span></span></div>
<div class="de1" style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">uemail<span class="sy0">=</span><span class="kw2">raw_input</span><span class="br0">(</span><span class="st0">"Enter your Email::"</span><span class="br0">)</span></span></div>
<div class="de2" style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">password<span class="sy0">=</span><span class="kw2">raw_input</span><span class="br0">(</span><span class="st0">"Enter your Password::"</span><span class="br0">)</span></span></div>
<div class="de1" style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">mailserver.<span class="me1">login</span><span class="br0">(</span><span class="kw2">str</span><span class="br0">(</span>uemail<span class="br0">)</span><span class="sy0">,</span><span class="kw2">str</span><span class="br0">(</span>password<span class="br0">)</span><span class="br0">)</span></span></div>
<div class="de2" style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">status<span class="sy0">,</span>count<span class="sy0">=</span>mailserver.<span class="kw3">select</span><span class="br0">(</span><span class="st0">"Inbox"</span><span class="br0">)</span></span></div>
<div class="de1" style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">status<span class="sy0">,</span>data<span class="sy0">=</span>mailserver.<span class="me1">fetch</span><span class="br0">(</span>count<span class="br0">[</span><span class="nu0">0</span><span class="br0">]</span><span class="sy0">,</span><span class="st0">"UID BODY [TEXT]"</span><span class="br0">)</span></span></div>
<div class="de2" style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;"><span class="kw1">print</span> data<span class="br0">[</span><span class="nu0">0</span><span class="br0">]</span><span class="sy0">,</span><span class="br0">[</span><span class="nu0">1</span><span class="br0">]</span></span></div>
<div style="text-align: justify;">
<span style="font-family: "Courier New",Courier,monospace;">mailserver.<span class="me1">close</span><span class="br0">(</span><span class="br0">)</span></span></div>
<br />
<b><span style="font-family: "Trebuchet MS",sans-serif;">Now, here's the working of the code:</span></b><br />
<span style="font-family: "Courier New",Courier,monospace;">imaplib</span><span style="font-family: "Trebuchet MS",sans-serif;"> is a file in your Python Libraries that lets you access</span> <span style="font-family: "Courier New",Courier,monospace;">imap</span><br />
<span style="font-family: "Courier New",Courier,monospace;">imap</span> <span style="font-family: "Trebuchet MS",sans-serif;">stands of Internet Message Access Protocol that allows you to retrieve and store messeges from your Email Account. Here we are using</span> <span style="font-family: "Courier New",Courier,monospace;">imap</span> <span style="font-family: "Trebuchet MS",sans-serif;">to access Gmail Account and retrieve a mail.</span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">IMAP4 is the latest imap version and SSL is a protocol to transfer private data to the internet and 993 is the IMAP port of G Mail. uemail and password are two variables storing data entered in them.</span><br />
<span style="font-family: "Courier New",Courier,monospace;">mailserver</span> <span style="font-family: "Trebuchet MS",sans-serif;">is the server of the Email Host, here in the case its G Mail. </span><br />
<span style="font-family: "Trebuchet MS",sans-serif;">Even I don't know what does this <span style="font-family: "Courier New",Courier,monospace;">status</span> does. <span style="font-family: "Courier New",Courier,monospace;">count</span> is a counting variable.</span><br />
<span style="font-family: "Courier New",Courier,monospace;">print</span><span style="font-family: "Trebuchet MS",sans-serif;"> prints the data. </span><br />
<span style="font-family: "Courier New",Courier,monospace;">close</span> <span style="font-family: "Trebuchet MS",sans-serif;">is for closing the G Mail server.</span><br />
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/06648542260836304057noreply@blogger.com0tag:blogger.com,1999:blog-6855824606273157567.post-62331527295648013282014-08-14T08:57:00.001+05:452014-08-14T08:57:27.839+05:45Getting Started With Python<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: large;">I am beginning to learn python. Since the past 6 or seven months, I am trying to learn this programming language but have been a failure in it. I never took it seriously. Everyone says it is easy to learn but, I cannot go up from the basics of it. </span></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="font-size: large;"> I created this blog so that I can post all the stuffs that I have done using python from today(August -14,2014). This way, I believe that I can remember what I have been learning and also share something new to other newbie beginners. </span></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="font-size: large;"> </span></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="font-size: large;"> My Solo motive of creating this blog is to put all the codes that I have written and what it does. I have not made it in any education purpose. So, no one can complain me or insult me saying that I don't know much about Python. I am a beginner and trying to learn new things.</span></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="font-size: large;">Today, I will try out something about extracting the email on the top from my G Mail Account. </span></span><br />
<br />
<span style="font-family: Verdana,sans-serif;"><span style="font-size: large;">Note: The codes written will be in <span style="font-family: "Courier New",Courier,monospace;">Courier New</span> font and the rest of the descriptions will be in Trebuchet font. </span></span><br />
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="font-size: large;"><span style="font-family: "Trebuchet MS",sans-serif;">Finally, In the end. </span></span></div>
<h2 style="text-align: left;">
Python is Fun!</h2>
</div>
Anonymoushttp://www.blogger.com/profile/06648542260836304057noreply@blogger.com0