Wednesday, November 27, 2013

Send Email through outlook using Java

Desktop.mail can open outlook with the subject and receipt but it does not support the attachment (RFC 2368)
JMail only supports SMTP, does not support outlook (?)
JMAPI does not support 64bit
The most flexible way should by using VBA
Or use autoit as the general solution

import java.awt.AWTException;
import java.awt.Desktop;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.net.URI;

public class MailService {

public static void main(String[] args) throws IOException, AWTException {
Desktop desktop = Desktop.getDesktop();
//does not support attachment
   String message = "mailto:myaccount@gmail.com?subject=New_Profile&body=seeAttachment&Attachment=C:/data/readme.txt";
   URI uri = URI.create(message);
   desktop.mail(uri);
   Robot robot =new Robot();
   robot.delay(2000);
   robot.keyPress(KeyEvent.VK_CONTROL);
   robot.keyPress(KeyEvent.VK_ENTER);
   robot.delay(2000);
   robot.keyRelease(KeyEvent.VK_ENTER);
   robot.keyRelease(KeyEvent.VK_CONTROL);
   System.exit(0);
}

}

Tuesday, November 26, 2013

I will make miracles

  Today my son borrowed a wonderful book from the library. Just copied here to help improve my English:

I will make miracles

Everyone keeps asking me,
When you get older, what will you be?

I say a plumber or pilot.
Or dance the ballet.
Though the truth is I don't really
know what to say.

But today I woke up and peeked out my left eyes.
And the sun had just started to climb to the sky.
That's when I realized it just might be fun
To spend every morning waking the sun.

Then I might stir up the waves in the ocean.
My undersea concert would
rock with commotion!

Next thing I'd do, I'd heal all the sick
With vanilla milk shakes,
creamy and thick!

I'd wake the dead, I'd wake them all,
And give them one last chance
to play ball!

What about the bad guys?
I'd help the police.

We'd send them away
and have some peace!

I'd make the world stop fighting!
I'd get it down in writing!
I'd shout it far and near.
And everyone would hear.

I'd lock the bad guys up in cages
And turn them into wise old sages.

I'll make miracles my mission
And be the number-one magician.

I'll meet everyone on Earth,
and ask about their dreams.
Because life is more,
much more than it seems.

My giant loaf of bread will cure the world of hunger,
And people who eat it will feel ten years younger!
And then for the child who has nothing to wear,
I'll sew her a dress. That will answer her prayer.

I will stamp out earthquakes, floods, and fire-
The world will stop shaking, be cooler and drier.

I will stretch out our days and our nights to feel longer
So everyone has enough time to grow stronger.

I'll fill up world with people who share,
With people who smile, with people who can share.

It might sound like God is who I want to be...
And maybe it's true. But here is the key:

To change the world from dark to bright,
First I should learn to read and write.


Wednesday, November 20, 2013

Friends S0601

chapel
vodka
hiccup
It was such a blur.
What time is your flight?
Are you asking me to have a "frienaissance"?
Where is the waitress? I'm starving.
It's a buffet, man.
How do I tell her without crushing her?
Tennis is more believable.
I can't have a mimosa with breakfast?
We're just gonna get an annulment.
You wanna play some Pai Gow?
Last night we let the dice decide.

Logback

Logback-classic module requires the presence of slf4j-api.jar and logback-core.jar in addition to logback-classic.jar on the classpath.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
logback is divided into three modules, logback-core, logback-classic and logback-access.
To ensure that all loggers can eventually inherit a level, the root logger always has an assigned level. By default, this level is DEBUG.
the initialization steps that logback follows to try to configure itself:
Logback tries to find a file called logback.groovy in the classpath.
If no such file is found, logback tries to find a file called logback-test.xml in the classpath.
If no such file is found, it checks for the file logback.xml in the classpath..
If neither file is found, logback configures itself automatically using the BasicConfigurator which will cause logging output to be
directed to the console.

Monday, November 11, 2013

Three little pigs

Little pig, little pig, let me come in.
No, no, not by the hair on my chinny chin chin.
Then I'll huff, puff and I'll blow your house in.

Paul said that the wicked wolf was wrong to say "blow your house in", it should be "blow your house down". I didn't believe it and check the story book again. It's really "blow your house in" but "blow in" is a slang for "arrive at a place suddenly". Anyway, it shows that Paul's English is excellent now.

The hair on one's chin is one's beard. In folklore, the beard was always considered special, or magical, or sacred, and taking an oath by one's beard was a standard practice. Notice, by the way, how in Act 4, Scene 1 of Shakespeare's Two Gentleman of Verona the Third Outlaw says (in response to the Second Outlaw's statement that they will listen to Valentine):
Ay, by my beard, will we, for he's a proper man.

Pigs do not have beards, of course, but they may have stray hairs on their chin that can at least serve the purpose for taking an oath.

Blow in: to arrive at a place suddenly, or surprisingly, or with a casual air.