26 March 2010

Read mail from your gmail account using JavaMail API throught IMAP

import java.io.IOException;
import java.util.Properties;

import javax.activation.DataHandler;
import javax.mail.*;

public class Gmail
{
    public static void main(String[] args) throws IOException
    {
        Properties props = System.getProperties();
        props.setProperty("mail.store.protocol", "imaps");

        try
        {
            Session session = Session.getDefaultInstance(props, null);
            Store store = session.getStore("imaps");
            store.connect("imap.gmail.com", "bangalore.pune.india", "malay123");

            Folder inbox = store.getFolder("Inbox");
            inbox.open(Folder.READ_ONLY);
            Message messages[] = inbox.getMessages();

            for (Message message : messages)
            {
                Multipart multipart = (Multipart) message.getContent();

                for (int x = 0; x < multipart.getCount(); x++)
                {
                    BodyPart bodyPart = multipart.getBodyPart(x);
                    String disposition = bodyPart.getDisposition();

                    if (disposition != null && (disposition.equals(BodyPart.ATTACHMENT)))
                    {
                        System.out.println("Mail have some attachment : ");
                        DataHandler handler = bodyPart.getDataHandler();
                        System.out.println("file name : " + handler.getName());
                    }
                    else
                    {
                        System.out.println(bodyPart.getContent());
                    }
                }
                System.out.println("-----------------------------------------------------------------");
            }
        }
        catch (NoSuchProviderException e)
        {
            e.printStackTrace();
            System.exit(1);
        }
        catch (MessagingException e)
        {
            e.printStackTrace();
            System.exit(2);
        }
    }
}

You can download JavaMail API from the following link
http://java.sun.com/products/javamail/downloads/index.html

Send mail from your gmail account using JavaMail API throught SMTPS

It's not uncommon that the outgoing mail needs to be encrypted using the SMTPS protocol.
It's the case for GMAIL for example.

msgsend.java
--------------------------------------------------------------------
import javax.mail.*;
import javax.mail.internet.*;
import java.util.Properties;

public class msgsend {

    public static void main(String[] argv) throws MessagingException {
        final String SMTP_HOST_NAME = "smtp.gmail.com";
        final int SMTP_HOST_PORT = 465;
        final String SMTP_AUTH_USER = "bangalore.pune.india@gmail.com";
        final String SMTP_AUTH_PWD  = "password";

            Properties props = new Properties();

            props.put("mail.transport.protocol", "smtps");
            props.put("mail.smtps.host", SMTP_HOST_NAME);
            props.put("mail.smtps.auth", "true");
            // props.put("mail.smtps.quitwait", "false");

            Session mailSession = Session.getDefaultInstance(props);
            mailSession.setDebug(true);
            Transport transport = mailSession.getTransport();

            MimeMessage message = new MimeMessage(mailSession);
            message.setSubject("Testing SMTP-SSL");
            message.setContent("This is a test", "text/plain");

            message.addRecipient(Message.RecipientType.TO,
                 new InternetAddress("malay.majithia@gmail.com"));

            transport.connect
              (SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_AUTH_USER, SMTP_AUTH_PWD);

            transport.sendMessage(message,
                message.getRecipients(Message.RecipientType.TO));
            transport.close();
   }
}

You can download JavaMail API from the following link

http://java.sun.com/products/javamail/downloads/index.html

25 March 2010

Introduction to new Language called HTML Applications(HTA)

Today we are asked to perform some task in our new project which includes some mail related  work. As we are Java/J2EE people, we are habitual to think in terms of java only.

But suddenly we have been introduced to a new language called HTML Application. In formal term its new language but its nothing but simple HTML+JavaScript/VBScript.

But its capable of performing lots of tasks like:-
1. Accessing local files
2. Registry Access(Read/Write)
3. FTP Access
4. Mail Retrieve from Outlook
and much more.

The following is one simple example of HTML Application hello.hta
<html>
<HEAD>
<TITLE>My Monster Application</TITLE>
<HTA:APPLICATION ID="oMyApp"
APPLICATIONNAME="monster"
BORDER="none"
CAPTION="no"
ICON="/graphics/creature.ico"
SHOWINTASKBAR="no"
SINGLEINSTANCE="yes"
SYSMENU="no"
WINDOWSTATE="maximize">
</HEAD>
<body>
HelloWorld using HTA
</body>
</html>

Now your first HTML Application is ready to run. To run the application just double click on the file and it will show the output.

23 March 2010

Bengaluru to Pune - Life changing scenario

I don't know whether my decision to get relocation from Bengaluru to Pune is right or wrong. But I asked and I got the relocation. And as per situation we are supposed to report at TCS, Magarpatta City, Pune on 24th March, 10am. Just one day for Bengaluru to Pune is difficult but we don't have any option.

So now we are moving from Bengaluru to Pune with the hope that we will get project soon. As TCS, Pune branch is known for R&D. So chances are there that we will get good project here. But in life luck always matter when I am there. So now its all depends.

Though I have been in Pune five times before this, but I have not seen much apart from MIT and Balewadi Stadium and some other place. And the place where we are staying Magarpatta city, I have seen nothing. But its great to be in Pune too. Life is rocking, I am not regretting for my decision as soon as city change is concern.

Hope to get good project soon. :)

22 March 2010

There are a lot which can be changed..

In life there are a lots of things that can be altered. TCS Bangalore Location is one of these.

After a long queue, when my turns its like very much confusing what I will get Kochi or Pune or Chennai or my current base location Bangalore..

After a list we 5 people got Bangalore, Telecom ISU which made me happy that I got what I was wanted. Namma Bengaluru. We were asked to report to our Telecom RMG at ITPL and got project interview in Lucent project.

But Interviewers are horrible like they are just want to break us. And someone said that when rape is not evitable enjoy it. But finally they wanted people who are willing to work on c and assembly only. So there was no chance so two of five got the project.

After these I wanted to change my location, the reasons are lot. One people is ready to get swap from Pune to Bangalore. So I asked and after so many tries finally I got Pune. :-)

The purpose of these story is not to make people feel that I won, but in Life HOPE means a lot and if you are determined then you will definitely get what you want to achieve.

Dream BIG, achieve BIG.

18 March 2010

Six Brilliant Doubts

1. If all the nations in the world are in debt, where did all the money go?

2. When dog food is new and improved tasty, who tastes it?

3. If the "black box" flight recorder is never damaged during a plan crash, why isn't the whole airplane made out of that stuff?

4. Who copyrighted the copyright symbol?

5. Can you cry under water?

6. Why do people say, "you've been working like a dog" when dogs just sit around all day?

15 March 2010

UB City Luxurious Mall

UB city is quite different from the other stereotypes malls present and coming up in India. It’s the mall set up by United Breweries Group Known as UB city. It’s a luxurious mall, which is huge and magnificent.

UB city is the mall with a difference. There are many malls in Bangalore like Garuda, forum, Big Bazaar, Bangalore central etc. but this is very different. At the entrance of the mall one can realize how big it isand who owns(Dr.Vijay Mallya). Large fountains are there at the gate. There are good restaurants like Rajasthani, Rajdhani, Subway and others to enjoy good food at. There are huge showrooms of famous designers from all over the world say Italy, France, England. There are showrooms of Rolex watches, Rado and many more brands. The style of display is what makes things different. The tiles, colour combination and other features are different. No doubt about the sales persons. They are very sophisticated and professional. Behind the mall is the office of UB group. The time to spent is less if there is nothing to buy but the place is good for a short visit and if someone is ready to loose some cash then no doubt he can be assured of the luxury and choices that are available. The mall is built to pamper.

05 March 2010

ILP Chalisa

2nd December ko Infocity me,
AHD07 ki batch thi aayi;
Kafi josh me the log sare,
Kyuki joining bhi thi badi der se aayi. (1)

58 logo ne join kiya tha,
Tareh tareh ke bhaat bhaat ke;
Punjab Delhi Himachal Shimla;
Rajasthan aur Gujarat ke. (2)

Pahele din orientation tha,
Kai logo ne lecture diya tha;
Tata ki history sun ke,
Apne aap pe garv bhi hua tha. (3)

Technical me Dr Scheme ne,
Saala bahut hi 'bore' kiye tha;
LS ke session me Anupam ne,
Hasa hasa ke lotpot kiya tha. (4)

Jayshree Satish aur Sanjukta ke session me,
Group activity kai humne ki thi;
Tabhi jaakar to kai logo ki,
Pratibha baahar aayi thi. (5)

Daffodil me diwar todi kisine,
Karni padi hum sab ko bharpaai;
Hamare hi paiso se humne,
New year ki party thi paayi. (6)

Block 3 aur Block 4 me rehte,
khate, pite aur aish the karte;
Har roj savere bathroom ke liye,
Andar andar hi race the karte. (7)

'Tie' kitno ko humne thi pehnaai,
Shave bhi har roj humne thi banaai;
9 baje office report karne ko,
Kai baar humne daud thi lagaai. (8)

Cool Point ki ice cream sabhi ko bhaai,
Big Bite me maggie hum sab ne khaai;
Dry state me sirf coke pikar,
Hitesh Tuli ne apni pyaas chhipaai. (9)

Nagpuja, Shreeji aur Jay Matarani,
Gujarati thali aur matke ka paani;
Dawat aur Shiv Shakti the mehanga,
Fir bhi ki waha bhi mijbaani. (10)

Serwer me milta south indian khana,
Rajbhog aur Punjab King ka taste;
Orange me jaate har 2 din par,
Sardar ka non veg tha best. (11)

Tower 3 ka khana aisa tha ghatiya,
Koi Pratham me gaya, kisi ne tiffin ka khaya;
Food court khulne ke intejaar me,
Tower 1 bhi log ja aaye. (12)

Padhai kam aur games jyada thi,
Dumb cherards, Killer aur Antakshari ki bol-bala thi;
Football ke scores hum predict karte the,
Cricket ke score pe najar rakhte the. (13)

CAT GATE ki exam di,
Bimari ke bahane chhutti bhi li;
Juzer chala gaya BHEL me aur,
Vijin ne bhi GSPC hath kar li. (14)

BBT WBT me khoye rehte,
Google karke answer likhte;
Jiska kabhi na naam bhi suna,
Unhi subjects ko pass bhi karte. (15)

Yash baba the BBT Topper,
Manan aata uske baad;
Itni aasaan si BBTs me,
Fail hua tha Neeraj do baar. (16)

WBT hoti thi badi hi simple,
100 laata har koi har baar;
Answer key bana ke class me ghumte,
5 minute me hota tha ek test paar. (17)

Bhupendra aur Chandravijay ne,
Kafi achchha Dr Scheme karwaya;
BM1 ke waqt hume pehli baar,
Jaalim Robo se intro karwarya. (18)

Aise me hi aa gaya EC1,
Tension badh gaya, ruk gayi masti;
D+ slots bhi shuru ho gaye,
Dr Scheme ne uda di susti. (19)

Tanmay ne kiya top EC1 me,
Tabhi hi aaya woh sab ki najar me;
Ek din ka maatam manakar,
Sab lag gaye fir mauj masti me. (20)

Weekend me koi Kankaria gaya,
Koi Akshardham ghumkar aaya;
Movies to har weekend hoti,
Har koi Cine max jaakar aaya. (21)

Rini ka gaana, Shamik ki acting,
Kalpana Juhee aur Ayush ka dance;
Vaibhav Medha ka teen tali garba,
Dipen ne mara Divya pe chance. (22)

Ravi Prachi ke lafde hue,
Shaival Mitali ke bhi charche hue;
Swati Juhee pe mar mite log,
Rucha ki ada ke diwane hue. (23)

Shivani aur Hiral ki hansi,
Tushar ke pyar me koi na fansi;
Woh chali gai Delhi aur,
Aahe bharta reh gaya Jay C. (24)

Suhrita ke gaane bade surile,
Lata Mangeshkar ki yaad dilate;
Komal ke gaane bade hi bedard,
Sunne walo ke kaan pakate. (25)

Nishtha ke chahne wale bahut the,
Chup rehte, kabhi bolte nahi the;
Nishtha bhi smart thi aisi,
Najar jhuka ke muskura leti thi. (26)

Munjal ke one liners Dipen ko satate,
Class me sir aaye to hum Vyomesh ko jagate;
'Sir' saamne baithe ho fir bhi,
Chain ki neend kai baar so jaate. (27)

Mihir ki shaktimaan ki acting par,
Log sabhi fida ho gaye;
Amit ki boli samjhte hue,
Na jaane kitne din lag gaye. (28)

Kushal ka har roj der se uthna,
Dhaval ka janmdin ko electric room me chhupna;
Malay ka hamesha "kuch bhi" bolna,
"Baki to koi problem nahi" kehna. (29)

Sandip jaisa sidha na koi,
Kishan ko Prabhu use kehta harkoi;
Laap aane par Ami bahut roi;
Raat bhar woh bilkul na soi. (30)

Allocation aakhiri din pe hua,
Kahi faili khushi, kahi faile gum;
Delhi milne par Jyoti ki,
Hansi hui thodi si kam. (31)

Divya ki woh latak matak chaal,
Rahul Bhateja ki apni hi style;
Siddharth ka foreign accent,
Ankit me dikhti UP ki style. (32)

Parul thi badi hi shant,
Anshika bhi chup rehti thi;
Kamaldeep thi badi hi sweet,
Aur savere jaldi uth jaati thi. (33)

Archana ka hamesha haste rehna,
Mitali ka Prachi ko shikayate karna;
Sandeepan ka chup sa rehna,
Shivani Swati ka saath na chhodna. (34)

Abhishek Vijay ka roj ka D+,
Sharmeen ka bhi koshish karna;
7 baje hi hostel me ho,
Fir bhi vaapis shart lagana. (35)

Naresh ne ultimatix aisa lock kiya,
17 din tak khul nahi paaya;
Trivendrum tak usne HR ko daudaya,
Puri TCS ko akele hi hilaya. (36)

Bijal Akanksha ka shant hi baihna,
Kaam pade to hi kuch bolna;
Parth Avani ka saath hi rehna,
Saath me ghumna, saath me khana. (37)

Medha ka Dipen ko Cuckoo kehna,
Puraane hindi gaane gaana;
Jay C ka chupke se mohabbat karna;
Tushar ka jabaan pe lagaam lagana. (38)

Raat ko jaagna, din me sona,
Savere hamesha late hi uthna;
I-Card bhulna, lift me atakna,
Late aakar defaulter hona. (39)

Ritesh, Shahid, Naresh aur Ravi,
Help unhi ki lete sabhi;
Yash, Manan aur Amit se,
J2EE sikhte sabhi LE. (40)

Doha(दोहा):
Bina mobile aur bina email ke, kabhi hamara samay na jaata,
Fir bhi itne pyaare dosto me, Humne ye suhana safar hai kaata;
Sab ko chhod jaane ka khayal, mere dil ko bilkul na bhaata,
Itne behtarin jo dost mile hai, Sab sath me bolo Thanks to Tata.

Author: Vaibhav Shah from AHD 07 ILP - 2009 Batch