Read ONE email from INBOX.
I have a method that bring all the messages from the inbox and displays its subject on a JSP. I need that when a user click on one mail another JSP displays the full email but I don't know how to get only the SELECTED email.
How do you select ONE mail from the Inbox ???
Any examples ?
Thanks.
Eli
I have my code on my home workstation.. so no examples right now.. but the answer to your question is yes you can.. it is possible to reference the emails in an inbox using in interger...
int mCount = folder.getMessageCount();
if (mCount < 1 ) {
// no new mail
} else {
// insert processing code here
Message message = folder.getMessage(1);
// this line above gets only the first message aka the newest in the inboxhence you can specify to get the first. or message(1);
(guess i lied about no examples :) )
j.
Similar Messages
-
I created a Message Filter to move email from Inbox to a Local Folder based on Date. The email headers were moved, but not the contents. Since I'm using IMAP, all the emails were deleted from the server.
I searched for similar problems and I followed one suggestion to "repair" one of the target Local Folders, but that made things worse. Now the header information (Subject, From, Date (now set to the date the transfer was done, not the email received date) is all blank.
The Local Folder properties indicate the email is contained in
mailbox:///C:/Users/Ted/AppData/Roaming/Thunderbird/Profiles/c65xcqqf.default/Mail/Local Folders/Archives.sbd/2010
I can see the messages from other Local Folders here, but the ones "moved" are empty.
Should this location be changed?
Is there some way to recover the email contents?
The info below is from the troubleshooting information tool:
Application Basics
Name: Thunderbird
Version: 31.5.0
User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0
Profile Folder: Show Folder
(Local drive)
Application Build ID: 20150222233048
Enabled Plugins: about:plugins
Build Configuration: about:buildconfig
Memory Use: about:memory
Mail and News Accounts
account2:
INCOMING: account2, , (none) Local Folders, plain, passwordCleartext
account5:
INCOMING: account5, , (imap) imap.googlemail.com:993, SSL, passwordCleartext
OUTGOING: smtp.googlemail.com:465, SSL, passwordCleartext, true
account6:
INCOMING: account6, , (imap) imap-mail.outlook.com:993, SSL, passwordCleartext
OUTGOING: smtp-mail.outlook.com:587, alwaysSTARTTLS, passwordCleartext, true
account7:
INCOMING: account7, , (imap) imap.comcast.net:993, SSL, passwordCleartext
OUTGOING: smtp.comcast.net:465, SSL, passwordCleartext, true
account8:
INCOMING: account8, , (imap) imap.comcast.net:993, SSL, passwordCleartext
OUTGOING: smtp.comcast.net:465, SSL, passwordCleartext, true
account9:
INCOMING: account9, , (imap) imap.comcast.net:993, SSL, passwordCleartext
OUTGOING: smtp.comcast.net:465, SSL, passwordCleartext, true
Crash Reports
Extensions
Lightning, 3.3.3, true, {e2fda1a4-762b-4020-b5ad-a41df1933103}
Manually sort folders, 1.1, true, [email protected]
Important Modified Preferences
Name: Value
browser.cache.disk.capacity: 358400
browser.cache.disk.smart_size_cached_value: 358400
browser.cache.disk.smart_size.first_run: false
browser.cache.disk.smart_size.use_old_max: false
extensions.lastAppVersion: 31.5.0
font.internaluseonly.changed: true
font.minimum-size.x-western: 10
font.name.monospace.el: Consolas
font.name.monospace.tr: Consolas
font.name.monospace.x-baltic: Consolas
font.name.monospace.x-central-euro: Consolas
font.name.monospace.x-cyrillic: Consolas
font.name.monospace.x-unicode: Consolas
font.name.monospace.x-western: Consolas
font.name.sans-serif.el: Calibri
font.name.sans-serif.tr: Calibri
font.name.sans-serif.x-baltic: Calibri
font.name.sans-serif.x-central-euro: Calibri
font.name.sans-serif.x-cyrillic: Calibri
font.name.sans-serif.x-unicode: Calibri
font.name.sans-serif.x-western: Calibri
font.name.serif.el: Cambria
font.name.serif.tr: Cambria
font.name.serif.x-baltic: Cambria
font.name.serif.x-central-euro: Cambria
font.name.serif.x-cyrillic: Cambria
font.name.serif.x-unicode: Cambria
font.name.serif.x-western: Cambria
font.size.fixed.el: 14
font.size.fixed.tr: 14
font.size.fixed.x-baltic: 14
font.size.fixed.x-central-euro: 14
font.size.fixed.x-cyrillic: 14
font.size.fixed.x-unicode: 14
font.size.fixed.x-western: 14
font.size.variable.el: 17
font.size.variable.tr: 17
font.size.variable.x-baltic: 17
font.size.variable.x-central-euro: 17
font.size.variable.x-cyrillic: 17
font.size.variable.x-unicode: 17
gfx.direct3d.last_used_feature_level_idx: 0
mail.openMessageBehavior.version: 1
mail.winsearch.enable: true
mail.winsearch.firstRunDone: true
mail.winsearch.global_reindex_time: 1387144538
mailnews.database.global.datastore.id: 11ee7f66-9920-4f7d-9c5e-a83d079bc6e
mailnews.database.global.views.conversation.columns: {"threadCol":{"visible":true,"ordinal":"1"},"flaggedCol":{"visible":true,"ordinal":"3"},"attachmentCol":{"visible":false…
mailnews.database.global.views.global.columns: {"threadCol":{"visible":true,"ordinal":"1"},"flaggedCol":{"visible":true,"ordinal":"3"},"attachmentCol":{"visible":false…
network.cookie.prefsMigrated: true
places.database.lastMaintenance: 1424815462
places.history.expiration.transient_current_max_pages: 104858
plugin.importedState: true
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_bgcolor: false
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_bgimages: false
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_colorspace:
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_command:
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_downloadfonts: false
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_duplex: 1515870810
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_edge_bottom: 0
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_edge_left: 0
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_edge_right: 0
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_edge_top: 0
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_evenpages: true
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_footercenter:
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_footerleft: &PT
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_footerright: &D
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_headercenter:
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_headerleft: &T
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_headerright: &U
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_in_color: true
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_margin_bottom: 0.5
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_margin_left: 0.5
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_margin_right: 0.5
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_margin_top: 0.5
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_oddpages: true
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_orientation: 0
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_page_delay: 50
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_paper_data: 1
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_paper_height: 11.00
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_paper_name:
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_paper_size_type: 0
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_paper_size_unit: 0
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_paper_width: 8.50
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_plex_name:
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_resolution: 1515870810
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_resolution_name:
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_reversed: false
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_scaling: 1.00
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_shrink_to_fit: false
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_to_file: false
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_unwriteable_margin_bottom: 0
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_unwriteable_margin_left: 0
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_unwriteable_margin_right: 0
print.printer_\\TED-PC\EPSON_Stylus_Photo_RX595_Series.print_unwriteable_margin_top: 0
security.disable_button.openCertManager: false
Graphics
Adapter Description: Intel(R) HD Graphics 4600
Vendor ID: 0x8086
Device ID: 0x0416
Adapter RAM: Unknown
Adapter Drivers: igdumdim64 igd10iumd64 igd10iumd64 igdumdim32 igd10iumd32 igd10iumd32
Driver Version: 10.18.10.3379
Driver Date: 12-18-2013
Direct2D Enabled: true
DirectWrite Enabled: true (6.3.9600.17111)
ClearType Parameters: ClearType parameters not found
WebGL Renderer: false
GPU Accelerated Windows: 2/2 Direct3D 10
AzureCanvasBackend: direct2d
AzureSkiaAccelerated: 0
AzureFallbackCanvasBackend: cairo
AzureContentBackend: direct2d
JavaScript
Incremental GC: 1
Accessibility
Activated: 0
Prevent Accessibility: 0
Library Versions
Expected minimum version
Version in use
NSPR
4.10.6
4.10.6
NSS
3.16.2.3 Basic ECC
3.16.2.3 Basic ECC
NSS Util
3.16.2.3
3.16.2.3
NSS SSL
3.16.2.3 Basic ECC
3.16.2.3 Basic ECC
NSS S/MIME
3.16.2.3 Basic ECC
3.16.2.3 Basic ECCFixed the Trouble Shooting information in previous post.
-
Recieved email from Computer Help at WHICH magazine with [Request ID :##55675##] : in the subject heading is crashing my THUNDERBIRD (and other programs) when I move the email from INBOX to local folders. The only work-around found so far is to shut them down with task manager, as they wont otherwise close.
However if I move the Reply with the same subject heading from my SENT box to LOCAL FOLDERS I dont get the problem.
Hav I found a faulty software trap in the base code.
Thunderbird is up to date and it is on a 64kb intel i7 quad processor 8G ram desktop using windows 7 latest update.To diagnose problems with Thunderbird, try one of the following:
*Restart Thunderbird with add-ons disabled (Thunderbird Safe Mode). On the Help menu, click on "Restart with Add-ons Disabled". If Thunderbird works like normal, there is an Add-on or Theme interfering with normal operations. You will need to re-enable add-ons one at a time until you locate the offender.
*Restart the operating system in '''[http://en.wikipedia.org/wiki/Safe_mode safe mode with Networking]'''. This loads only the very basics needed to start your computer while enabling an Internet connection. Click on your operating system for instructions on how to start in safe mode: [http://windows.microsoft.com/en-us/windows-8/windows-startup-settings-including-safe-mode Windows 8], [http://windows.microsoft.com/en-us/windows/start-computer-safe-mode#start-computer-safe-mode=windows-7 Windows 7], [http://windows.microsoft.com/en-us/windows/start-computer-safe-mode#start-computer-safe-mode=windows-vista Windows Vista], [http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/boot_failsafe.mspx?mfr=true" Windows XP], [http://support.apple.com/kb/ht1564 OSX]
; If safe mode for the operating system fixes the issue, there's other software in your computer that's causing problems. Possibilities include but not limited to: AV scanning, virus/malware, background downloads such as program updates. -
How do I read a Email from the MS exchange server
could any one tell me as to how i could read the mail from the exchange server and store it in a seperate folder.
I have an application which reads the mail from our mail server and then writes the body of the message into a file and then deletes the email anf those values are then read from that file and stored into the database .
Here is the code which pops the mail from the exchange server and then stores it into a file .
import javax.mail.*;
import com.sun.mail.pop3.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.util.*;
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author
* @version 1.0
public class SunMailConnection implements Runnable{
boolean suspendFlag;
ErrorLogWriter log = new ErrorLogWriter("SunMail.log");
public SunMailConnection() {
this.start() ;
public void run(){
try {
int start = 1;int end = -1;
String host = "cyde-cehh-exh1";//the local exchange server name AND DOESNT WORK IF U CONNECT TO EXT MAIL SERVER DIRECTLY
//DUE TO SECURED AUTHORISATION
//String host ="http://www.conergy-electronics.de";
String username ="SunReader\\Sun\\saa";
String password = "xxxxx";
// Create empty properties
Properties props = new Properties();
props.put("mail.protocol.store","pop3");
// Get session
Session session = Session.getDefaultInstance(props, null);
Provider[] p = session.getProviders();
//for (int i=0;i<p.length;i++) System.out.println(p.getProtocol());
// Get the store
Store store = session.getStore("pop3");
store.connect(host, username, password);
// Get folder
Folder folder = store.getFolder("INBOX");
if (folder == null || !folder.exists()) {
//System.out.println("Invalid folder: " + folder.getName());
log.write("Invalid folder: " + folder.getName()) ;
System.exit(1);
folder.open(Folder.READ_WRITE);
//Get the number of Unread Messages
int count = folder.getUnreadMessageCount();
if (count == 0) { // No messages in the source folder
//System.out.println(folder.getName() + " is empty");
// Close folder, store and return
folder.close(false);
store.close();
return;
if (end == -1)
end = count;
// Get the message objects to copy
log.write("Test");
Message[] msgs = folder.getMessages(start, end);
//System.out.println("Moving " + msgs.length + " messages");
//log.write("Moving " + msgs.length + " messages") ;
if (msgs.length != 0) {
//If there is any mail
//System.out.println(msgs.length );
//read mail from server into files
MoveMessageTo saveFile = new MoveMessageTo(msgs);
if(saveFile.createdFile=true){
folder.setFlags(msgs,new Flags(Flags.Flag.SEEN),true);
//delete flag set here to remove the email from INBOX
folder.setFlags(msgs, new Flags(Flags.Flag.DELETED), true);
//folder.expunge(); //removes messages marked as deleted
//check for deleting messages
for (int i = 0; i < msgs.length; i++) {
if (!msgs[i].isSet(Flags.Flag.DELETED))
log.write("Message # "+msgs[i]+" not deleted.");
//else System.out.println("Message "+i+"-is deleted") ;
// Close connection
folder.close(true);
// dfolder.close(false);
store.close();
//this.start() ;
}catch (Exception ex) {
ex.printStackTrace() ;
//this.t.start();
public void start(){
try {
while(this!= null){
this.run() ;
Thread.sleep(15000);//every 15 seconds
}catch (Exception ex) {
ex.printStackTrace();
public void exit(){
this.exit();
System.out.println("Exit");
public static void main(String[] args) {
SunMailConnection sunMail = new SunMailConnection();
This is to show the messages
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
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;
public static void main(String argv[]) {
int msgnum = -1;
int optind;
protocol = "pop3";
host="cyde-cehh-exh1";
user="SunReader\\Sun\\saa";
password="xxxxxx";
mbox="INBOX";
/*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("-m")) {
showMessage = 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]");
System.out.println(
"or msgshow -m [-v] [-D] [-s] < msg");
System.exit(1);
} else {
break;
try {
// if (optind < argv.length)
// msgnum = Integer.parseInt(argv[optind]);
//msgnum = 5;
// Get a Properties object
Properties props = System.getProperties();
// Get a Session object
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
if (showMessage) {
MimeMessage msg = new MimeMessage(session, System.in);
dumpPart(msg);
System.exit(0);
// Get a Store object
Store store = null;
if (url != null) {
URLName urln = new URLName(url);
store = session.getStore(urln);
store.connect();
} else {
if (protocol != null)
store = session.getStore(protocol);
else
store = session.getStore();
// Connect
if (host != null || user != null || password != null)
store.connect(host, port, user, password);
else
store.connect();
// Open the Folder
Folder folder = store.getDefaultFolder();
if (folder == null) {
System.out.println("No default folder");
System.exit(1);
folder = folder.getFolder(mbox);
if (folder == null) {
System.out.println("Invalid folder");
System.exit(1);
// try to open read/write and if that fails try read-only
try {
folder.open(Folder.READ_WRITE);
} catch (MessagingException ex) {
folder.open(Folder.READ_ONLY);
int totalMessages = folder.getMessageCount();
if (totalMessages == 0) {
System.out.println("Empty folder");
folder.close(false);
store.close();
System.exit(1);
if (verbose) {
int newMessages = folder.getNewMessageCount();
System.out.println("Total messages = " + totalMessages);
System.out.println("New messages = " + newMessages);
System.out.println("-------------------------------");
if (msgnum == -1) {
// Attributes & Flags for all messages ..
Message[] msgs = folder.getMessages();
// Use a suitable FetchProfile
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfile.Item.FLAGS);
fp.add("X-Mailer");
folder.fetch(msgs, fp);
for (int i = 0; i < msgs.length; i++) {
System.out.println("--------------------------");
System.out.println("MESSAGE #" + (i + 1) + ":");
dumpEnvelope(msgs[i]);
// dumpPart(msgs[i]);
} else {
System.out.println("Getting message number: " + msgnum);
Message m = null;
try {
m = folder.getMessage(msgnum);
dumpPart(m);
} catch (IndexOutOfBoundsException iex) {
System.out.println("Message number out of range");
folder.close(false);
store.close();
} catch (Exception ex) {
System.out.println("Oops, got exception! " + ex.getMessage());
ex.printStackTrace();
System.exit(1);
System.exit(0);
public static void dumpPart(Part p) throws Exception {
if (p instanceof Message)
dumpEnvelope((Message)p);
/** Dump input stream ..
InputStream is = p.getInputStream();
// If "is" is not already buffered, wrap a BufferedInputStream
// around it.
if (!(is instanceof BufferedInputStream))
is = new BufferedInputStream(is);
int c;
while ((c = is.read()) != -1)
System.out.write(c);
pr("CONTENT-TYPE: " + p.getContentType());
String filename = p.getFileName();
if (filename != null)
pr("FILENAME: " + filename);
* Using isMimeType to determine the content type avoids
* fetching the actual content data until we need it.
if (p.isMimeType("text/plain")) {
pr("This is plain text");
pr("---------------------------");
if (!showStructure)
System.out.println((String)p.getContent());
} else if (p.isMimeType("multipart/*")) {
pr("This is a Multipart");
pr("---------------------------");
Multipart mp = (Multipart)p.getContent();
level++;
int count = mp.getCount();
for (int i = 0; i < count; i++)
dumpPart(mp.getBodyPart(i));
level--;
} else if (p.isMimeType("message/rfc822")) {
pr("This is a Nested Message");
pr("---------------------------");
level++;
dumpPart((Part)p.getContent());
level--;
} else if (!showStructure) {
* If we actually want to see the data, and it's not a
* MIME type we know, fetch it and check its Java type.
Object o = p.getContent();
if (o instanceof String) {
pr("This is a string");
pr("---------------------------");
System.out.println((String)o);
} else if (o instanceof InputStream) {
pr("This is just an input stream");
pr("---------------------------");
InputStream is = (InputStream)o;
int c;
while ((c = is.read()) != -1)
System.out.write(c);
} else {
pr("This is an unknown type");
pr("---------------------------");
pr(o.toString());
} else {
pr("This is an unknown type");
pr("---------------------------");
public static void dumpEnvelope(Message m) throws Exception {
pr("This is the message envelope");
pr("---------------------------");
Address[] a;
// FROM
if ((a = m.getFrom()) != null) {
for (int j = 0; j < a.length; j++)
pr("FROM: " + a[j].toString());
// TO
if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
for (int j = 0; j < a.length; j++)
pr("TO: " + a[j].toString());
// SUBJECT
pr("SUBJECT: " + m.getSubject());
// DATE
Date d = m.getSentDate();
pr("SendDate: " +
(d != null ? d.toString() : "UNKNOWN"));
// FLAGS
Flags flags = m.getFlags();
StringBuffer sb = new StringBuffer();
Flags.Flag[] sf = flags.getSystemFlags(); // get the system flags
boolean first = true;
for (int i = 0; i < sf.length; i++) {
String s;
Flags.Flag f = sf[i];
if (f == Flags.Flag.ANSWERED)
s = "\\Answered";
else if (f == Flags.Flag.DELETED)
s = "\\Deleted";
else if (f == Flags.Flag.DRAFT)
s = "\\Draft";
else if (f == Flags.Flag.FLAGGED)
s = "\\Flagged";
else if (f == Flags.Flag.RECENT)
s = "\\Recent";
else if (f == Flags.Flag.SEEN)
s = "\\Seen";
else
continue; // skip it
if (first)
first = false;
else
sb.append(' ');
sb.append(s);
String[] uf = flags.getUserFlags(); // get the user flag strings
for (int i = 0; i < uf.length; i++) {
if (first)
first = false;
else
sb.append(' ');
sb.append(uf[i]);
pr("FLAGS: " + sb.toString());
// X-MAILER
String[] hdrs = m.getHeader("X-Mailer");
if (hdrs != null)
pr("X-Mailer: " + hdrs[0]);
else
pr("X-Mailer NOT available");
static String indentStr = " ";
static int level = 0;
* Print a, possibly indented, string.
public static void pr(String s) {
if (showStructure)
System.out.print(indentStr.substring(0, level * 2));
System.out.println(s);
This code is to move the message into a file
import javax.mail.*;
import com.sun.mail.pop3.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.util.*;
import java.io.*;
//This class copies the content of the received e-mail into files. The file names are given by
//the urgent flag value and the subject
public class MoveMessageTo {
boolean createdFile = true;
static final byte urgentFlagPos=13;
public MoveMessageTo() {
public MoveMessageTo(Message[] msgs) {
if(msgs.length != 0)
try {
for(int i = 0;i<msgs.length ;i++){
//Reads the content of the mail into an Object
Object currMultipart = msgs[i].getContent();
//converts this object into a String and then to a byte array, so we can read the urgnet flag
String content=(String)currMultipart;
byte[] testBytes=content.getBytes();
//The urgent flag is the first digit in the filename
StringBuffer fileName=new StringBuffer();
if (testBytes.length>urgentFlagPos)
fileName.append(new Byte(testBytes[urgentFlagPos]).toString());
//Then comes the subject of the e-mail
String mailSubject=msgs[i].getSubject();
if (mailSubject.length()>0)
fileName.append(mailSubject);
else fileName.append("noSubject");
fileName.append(".dat");
//create a directory to save the files
File baseDir = new File("c:/EMails/New");
baseDir.mkdirs();
//create file for with the subject as name
File eFile = new File(baseDir+"/"+fileName.toString());// creates a file by name of email subject
//Opening an stream for writting to the files
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(eFile));
ObjectOutputStream oos = new ObjectOutputStream(bos);
//Writing the message body to the file
oos.writeObject(currMultipart) ;
//Closing the stream
oos.flush() ;
oos.close() ;
createdFile = true;
}catch (Exception ex) {
createdFile = false;
System.out.println("eFile is not created ");
ex.printStackTrace() ;
public static void main(String[] args) {
MoveMessageTo moveMessageTo1 = new MoveMessageTo();
This code is if there is an error in reading a file it will write those error into the file
import java.io.*;
import javax.swing.*;
import java.awt.Color;
import javax.swing.border.*;
//This class appends an error message to the log file
public class ErrorLogWriter {
//JPanel jPanel2 = new JPanel();
//Border border1;
String logDirectory="c:/EMails/log/";
File errFile; //= new File(errDir+"/"+"errorLog.dat");
//The constructor initializes the errFile given the filename
public ErrorLogWriter(String fileName) {
errFile=new File(logDirectory+fileName);
/*try {
jbInit();
}catch(Exception e) {
e.printStackTrace();
public void write(String writeStr){
try {
//Creates directory if doesn't exist
File errDir = new File(logDirectory);
errDir.mkdirs() ;
//If the directory exists...
if(errDir.isDirectory()){
//File errFile = new File(errDir+"/"+"errorLog.dat");
byte[] lastContent=new byte[0];
//If there is already a file with this name: Read its content so it can be preserved
if (errFile.exists()){
FileInputStream fis=new FileInputStream(errFile);
//Read everything into the byte array
lastContent=new byte[fis.available()];
fis.read(lastContent);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(errFile));
PrintWriter oos = new PrintWriter(bos);
String newWriteString=new String(lastContent);
writeStr.trim() ;
//Appends the new string to the old content
newWriteString+=writeStr;
newWriteString+="\n";
//writes everthing back to the file
oos.write(newWriteString) ;
oos.flush();
oos.close();
}catch (Exception ex) {
ex.printStackTrace() ;
public static void main(String[] args) {
ErrorLogWriter log = new ErrorLogWriter("logerror.log");
log.write("Hello Log!") ;
All these file are in one package called SunMail and i run this in jbuilder in 4.0 ,I get the following error
eFile is not created
java.lang.ClassCastException: javax.mail.internet.MimeMultipart
at MoveMessageTo.<init>(MoveMessageTo.java:26)
at SunMailConnection.run(SunMailConnection.java:86)
at SunMailConnection.start(SunMailConnection.java:118)
at SunMailConnection.<init>(SunMailConnection.java:21)
at SunMailConnection.main(SunMailConnection.java:133)
I know the it would be difficult if anyone could help me out it would be a great favour !!!
pls help me out of this !!!! -
Siri says she can't read my email from the iphone5s lock screen when I'm using the standard headphones, but I could do that on 4s. How can I get my 5s to do that?
Hi Liz,
Sorry to hear you are having a similar problem. Last night I went to the tool bar at the top of iphoto, clicked on "File", then clicked "Browse Backups" in the drop down menu. I have an external hard drive that is set up to Time Machine. The Browse Backups opened the iphoto pages in the Time Machine. I selected a date one day ahead of the day I performed the now infamous update, and it showed my iphoto library as it had existed that day. I then clicked "Restore Library" at the bottom right corner of the Time Machine screen. Roughly 2 hours later my iphoto was back to normal. When I opened iphoto there was a message saying I need to upgrade my program to be compatible with the new version of iphoto(version 9.2.1). I clicked "Upgrade" and within seconds it had done whatever upgrading it needed to do.
The only glitch in the restoration was that it restored the library as it appeared last week, so I no longer had photos I had imported this past weekend. I simply went back to the Browse Backups in the drop down menu, when Time Machine opened I selected the page showing my pictures from this weekend and again said to Restore Library. Roughly 45 minutes later the library was restored including the most recent photos.
I am now a happy camper.
I don't know if any of this will be of help to you because your email says you are having trouble with photos imported after the upgrade was performed. Have you had any pop up notices when you first open iphoto, that tell you you need an upgrade to be compatible with the new iphoto? If so have you clicked "upgrade"?
Good luck Liz, if you have Time Machine running as a back up to your library, maybe you wil be able to get help there, by following my instructions above. Otherwise, good luck with your investigations. I'd be interested in hearing how you make out.
Karen -
How can I permantely delete email information from my iphone4?
I deleted all my emails from inbox and trash, but the Mail "file" still has 2GB...Does anyone have an answer to this problem? It's been 4 or 5 days now and iCloud still says I have 0kb of 5GB available, and 6.1GB of mail on iCloud. I guess that's better than yesterday when it said I had 8.3GB of mail. Does anyone know if it simply takes Apple a week to actually empty a mailbox?
thanks in advance, hopefully tomorrow it says I have only 4GB of non-existent mail and I can start using it again... -
Move email from inbox to another folder, still appears in inbox. How to solve?
move email from inbox to another folder, still appears in inbox. How to solve?
Fixed the Trouble Shooting information in previous post.
-
Reading one line from a text file into an array
i want to read one line from a text file into an array, and then the next line into a different array. both arays are type string...i have this:
public static void readAndProcessData(FileInputStream stream){
InputStreamReader iStrReader = new InputStreamReader (stream);
BufferedReader reader = new BufferedReader (iStrReader);
String line = "";
try{
int i = 0;
while (line != null){
names[i] = reader.readLine();
score[i] = reader.readLine();
line = reader.readLine();
i++;
}catch (IOException e){
System.out.println("Error in file access");
this section calls it:
try{
FileInputStream stream = new FileInputStream("ISU.txt");
HighScore.readAndProcessData(stream);
stream.close();
names = HighScore.getNames();
scores = HighScore.getScores();
}catch(IOException e){
System.out.println("Error in accessing file." + e.toString());
it gives me an array index out of bounds erroroh wait I see it when I looked at the original quote.
They array you made called names or the other one is prob too small for the amount of names that you have in the file. Hence as I increases it eventually goes out of bounds of the array so you should probably resize the array if that happens. -
Reading my email from my iPad which is no longer allowing me to do. Thanks!
Hey there palmierl,
Welcome to Apple Support Communities.
It sounds like there’s an issue sending and receiving emails from your Gmail account on your iPad. Take a look at the article linked below, the troubleshooting suggestions it provides will likely resolve the issue.
Gmail account cannot get or send email in iOS - Apple Support
Cheers,
-Jason -
Why can't I read my emails from my iPad mailbox on my iPad today?Each message is replaced by the comment "This message has not been downloaded from the server."thank you
In which case, clearly communicating the intent would have been a better solution. The steps do apply. A more appropriate response would have been "tried that, no change".
Regardless of whether they fixed the problem or not, they do apply.
If English is not your native language, I would strongly encourage you to post in your native language going forward.
If basic troubleshooting has not resolved the issue, the next step is to take the device to Apple for evaluation. -
cant delete emails from inbox.
when i click the delete button on inbox this message appears on the bottom of the screen,
The current operation on inbox did not succeed, the mail server for account [email protected] responded [ TRY CREATE ] mail box name does not exist or is not selectable.
please advise thanksthanks for your response, still no luck with deleting messages problem. this problem just started without us doing anything different than we normally do,we tried deleting to trash but we still get the same message along the bottom of the screen
thanks from Judy -
I updated to FoxFire 7 today and then read an email from my school, they said do not update to 7 - it interfears with class email, how do I un-update, please.
See https://support.mozilla.com/en-US/kb/Installing%20a%20previous%20version%20of%20Firefox
-
Emails from Inbox moving into Outbox one at a time, can't stop them!!!
This behavior just started - I'm using Mail 3.6 (936) and OSX 10.5.8. My Outbox contantly has one email in it, and the email is always an old one taken from my Inbox... an email TO me, and not one I am trying to send. If I delete the email from the Outbox, then click out of/back into the Outbox, another single email from my Inbox will have taken its place. Starting Mail with these emails in the Outbox results in an SMTP error because the mail is not 'sendable'... every time, since I am unable to completely clean out the Outbox.
I've tried re-starting, rebuilding all mailboxes, etc... with no success. What happened here?Quit Mail, and in the Finder open Home/Library/Mail/Mailboxes and locate the Outbox.mbox folder. Delete this folder and relaunch Mail. When you next compose and send a message Mail will create a new Outbox.mbox.
See if this behavior is corrected?
Ernie -
How do I move multiple emails from Inbox to a specific folder?
I have left a lot of emails in my Inbox that should have been moved to specific folders. How do I move them in bulk to their specific folders other than moving each one individually. I have highlighted the messages concerned by searching and then selecting all. I then click on move to....
Nothing seems to be happening....I'm sure there's probably a step I'm missing here. What would it be??
A similar problem occurs when I want to do a mass delete of emails from a specific sender....I did all that and nothing happened. As it happens, I did manage to deal with the problem, but in a rather convoluted and tedious manner. I went into Edit, Find, and Search messages, typed in the criteria and the messages I wanted moved came up. However, there was no option to "Select All" so I had to highlight each one and then move the lot to the specific folder....that also worked for the delete problem. That is a workable solution to my problem, but the lack of a "select all" option made it very time consuming. However, I guess it's a notice to me to remember to sort my emails more often.
Thanks for replying.... -
How do i delete phantom emails from inbox?
My inbox details that there are 3 unread or new messages ... but there is not, i've tried to search for unread messages to delete but no luck. I've gone on my laptop to delete the messages and there are 0 unread messages in my inbox....What to do?
I posted this in another thread - a fix for this happening with Gmail:
I tried all the fixes here for an identical issue with my gmail account, but kept being left with 26,000+ allegedly unread emails on the iphone 5 after upgrading....
Now, it seems to be OK after the following routine, done on my PC (NB not sure how applicable this is to other email accounts)
1. (very important) - click on All Mail from the gmail menu on the left hand side of the screen (if you can't see this, it'll be revealed be selecting 'More' from the menu list). (It would appear that the emails that the iphone is referring to are not, in fact, just the ones in the inbox..... )
2. Click the 'down' arrow on the right hand end of the gmail search box (it's just by the blue button with the magnifying glass)
3. In the 'Doesn't Have' field in the Search menu, enter some gobbledygook - like "asgjihg567vfd" - something that you are certain will not be in any email. That means that all of the mail, including long-term deleted mail (not just the stuff that appears to figure in your bin), will get selected
4. In the left hand of the three grey boxes above the emails (the one with the square on it), select 'All'
5. You will see on the bar above the emails that a message comes up saying - "All 20 conversations on this page are selected. Select all conversations that match this search". Click on this to select, literally, all your emails - past, present, binned, spam, etc.
6. From the right hand control box above the emails (the one saying 'More'), select 'Mark as read'. This will take a few moments, but will work through them all.
7. When you go into the gmail account on your phone, you should see the unread email count miraculously disappear when it syncs.
This has worked for me and I hope it stays this way! The trick is that you may have lots of unread emails that you binned ages ago - but these have been resurrected through the miracle that is iOS7.
FWIW, I very much regret upgrading to iOS7 and have written to Tim Cook telling him that it's going to lose him customers - not that I expect that he will see my mail, or answer, or that he cares.......
Maybe you are looking for
-
Macbook Pro fails on startup after drive format and OSX reinstall
Hi all, I have a 2012 15'' Retina Macbook Pro - pretty new, so it surprises me I'm having this issue. The problem was pretty sudden - one day upon startup, I would be immediately told that Finder has closed unexpectedly. From this point on,
-
Adjust position and size of textField and button...
Dear All, I have the following sample program which has a few textFields and a button, but the positions are not good. How do I make the textField to be at the right of label and not at the bottom of the label ? Also how to adjust the length of textF
-
Overloaded Java methods in XSLT extensions?
Hello, when using Java classes as XSLT extensions, is it possible to use overloaded methods at all? I get "XSL-1042: Extension function error: Overloaded method 'format'" when doing that. I studied Steve Muench's book, pages 607-611, and came up with
-
hi all, How to import a list of phone numbers from ms access, excel sheet into an array .. ? Message was edited by: devsu
-
Move library to save during reinstall
My son has an older ipod. He upgraded to whatever the itunes is now...7xx. The sync freezes. The ipod itself has been reset, so there is nothing on it. How do I move/save his library on his PC (and move it back again) so that I don't lose it when I u