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: http://pastebin.com/5zDkYx1g
Below is given the code. You are allowed to try it out and even do something extra with this piece of code:
Now, here's the working of the code:
imaplib is a file in your Python Libraries that lets you access imap
imap stands of Internet Message Access Protocol that allows you to retrieve and store messeges from your Email Account. Here we are using imap to access Gmail Account and retrieve a mail.
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.
mailserver is the server of the Email Host, here in the case its G Mail.
Even I don't know what does this status does. count is a counting variable.
print prints the data.
close is for closing the G Mail server.
Below is given the code. You are allowed to try it out and even do something extra with this piece of code:
import imaplib
mailserver=imaplib.IMAP4_SSL("imap.gmail.com",993)
uemail=raw_input("Enter your Email::")
password=raw_input("Enter your Password::")
mailserver.login(str(uemail),str(password))
status,count=mailserver.select("Inbox")
status,data=mailserver.fetch(count[0],"UID BODY [TEXT]")
print data[0],[1]
mailserver.close()
Now, here's the working of the code:
imaplib is a file in your Python Libraries that lets you access imap
imap stands of Internet Message Access Protocol that allows you to retrieve and store messeges from your Email Account. Here we are using imap to access Gmail Account and retrieve a mail.
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.
mailserver is the server of the Email Host, here in the case its G Mail.
Even I don't know what does this status does. count is a counting variable.
print prints the data.
close is for closing the G Mail server.