This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes receiving attachments using javamail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "receiving attachments using javamail" Watch "receiving attachments using javamail" New topic
Author

receiving attachments using javamail

vidhya subramaniam
Ranch Hand

Joined: Jul 14, 2001
Posts: 91
I have 2 doubts ....
Firstly, I would like to save attachments in a dir using javamail. I found some sample codes for receiving messages in the javamail package but not anything for saving the files. What additional do I have to add in my receiving messages code?
If someone have any source code can you please send it to me. You can even mail me at vidhya.subramaniam@omnifax.xerox.com
Secondly the code that I use to receive messages goes like this
public class msgshow {
static String protocol;
static String host = null;
static String user = null;
static String password = null;
static String mbox = "INBOX";
static String url = null;
static int port = -1;
static boolean verbose = false;
static boolean debug = false;
static boolean showStructure = false;
static boolean showMessage = false;
static boolean showAlert = false;
static boolean saveAttachments = false;
static int attnum = 1;
public static void main(String argv[]) {
int msgnum = -1;
int optind;
InputStream msgStream = System.in;
for (optind = 0; optind < argv.length; optind++) {
if (argv[optind].equals("-T")) {
protocol = argv[++optind];
} else if (argv[optind].equals("-H")) {
host = argv[++optind];
} else if (argv[optind].equals("-U")) {
user = argv[++optind];
} else if (argv[optind].equals("-P")) {
password = argv[++optind];
} else if (argv[optind].equals("-v")) {
verbose = true;
} else if (argv[optind].equals("-D")) {
debug = true;
} else if (argv[optind].equals("-f")) {
mbox = argv[++optind];
} else if (argv[optind].equals("-L")) {
url = argv[++optind];
} else if (argv[optind].equals("-p")) {
port = Integer.parseInt(argv[++optind]);
} else if (argv[optind].equals("-s")) {
showStructure = true;
} else if (argv[optind].equals("-S")) {
saveAttachments = true;
} else if (argv[optind].equals("-m")) {
showMessage = true;
} else if (argv[optind].equals("-a")) {
showAlert = true;
} else if (argv[optind].equals("--")) {
optind++;
break;
} else if (argv[optind].startsWith("-")) {
System.out.println(
"Usage: msgshow [-L url] [-T protocol] [-H host] [-p port] [-U user]");
System.out.println(
"\t[-P password] [-f mailbox] [msgnum] [-v] [-D] [-s] [-S] [-a]");
System.out.println(
"or msgshow -m [-v] [-D] [-s] [-S] < msg");
System.exit(1);
} else {
break;
}
}
Can someone explain what the comparison with 's',S,'T','H','P', etc stand for?
Thanks,
Vidhya
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by vidhya subramaniam:
............
Thanks,
Vidhya

See the PDF this has an example to read email with attachment at the end. http://www.jaydeetechnology.co.uk/planetjava/tutorials/language/javamail2.pdf
I never used it.


Spritle Software Blogs
 
wood burning stoves
 
subject: receiving attachments using javamail
 
Similar Threads
Java mail
javax.mail.MessagingException: Connection dropped by server?; Error
javamail : Could not connect to SMTP host
Need some help me java mail-smtp
Java mail