Retrieve mail from Gmail account with pop3???
I want to retrieve e-mail from my account on Gmail in my application, but I have a problem. I cant establishe a connection with pop3 server...
Do you have an example (full) in Java code for retrieving a mail from Gmail account.
I used the example from JavaMail Api 1,4 Specifications, but I have a problem with the parameters. (protocol null), and I dont know why...
Help me, please...
i hv retrived messages from gmail.but i m geting problem at the time ......
when i m reading mail which hava attachment.........
it is only showing attachment name...but not shoing the body part....
this is my programe........
plz any body help me its very urgent.........
give me a programe how to find the attachment name with body part........
//java msgshow -D -T pop3s -H pop.gmail.com -U user -P passwd
package MailServer;
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.util.Date ;
public class msgshow
static String protocol;
static String host = null;
static String user = null;
static String password = null;
static String mbox = null;
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;
static Message[] msgs = null;
static String body = "";
static String attachment = "";
static String indentStr = " ";
static int level = 0;
static String from = "";
static String subject = "";
static Vector v ;
public Vector v1;
static Date date;
public Vector show()
int msgnum = -1;
int optind;
InputStream msgStream = System.in;
v = new Vector();
try
// Get a Properties object
Properties props = System.getProperties();
// Get a Session object
//debug = true;
Session session = Session.getInstance(props, null);
//session.setDebug(debug);
// Get a Store object
Store store = null;
protocol = "pop3s";
store = session.getStore(protocol);
host = "imap.gmail.com";
user = "techzain";
password = "zain1234";
// Connect
store.connect(host,port, user, password);
//System.out.println ("connected");
// Open the Folder
Folder folder = store.getDefaultFolder();
mbox = "INBOX";
folder = folder.getFolder(mbox);
//System.out.println ("opened inbox");
// 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);
// Attributes & Flags for all messages ..
msgs = folder.getMessages();
//System.out.println (msgs.length);
for(int x=0;x<1;x++)
try
//System.out.println ("inside for");
Address[] addList=msgs[x].getFrom();
if(addList.length>0)
from=((InternetAddress)addList[0]).getAddress();
subject=msgs[x].getSubject();
//body=(String)msgs[x].getContent();
date=msgs[x].getSentDate();
//body=(String)msgs[x].getContent();
//msgs[x].setFlag(Flags.Flag.SEEN,true);
if(msgs[x].isMimeType("multipart/*"))
boolean bbb=msgs[x].isSet(Flags.Flag.SEEN);
System.out.println (bbb);
Multipart multipart=(Multipart)msgs[x].getContent();
for(int i=0,n=multipart.getCount();i<n;i++)
{Part part=multipart.getBodyPart(i);
if(i==0)
body=part.getContent().toString();
else
//body=(String)msgs[x].getContent();
attachment=part.getFileName();
else
boolean bbb1=msgs[x].isSet(Flags.Flag.SEEN);
System.out.println (bbb1);
body=(String)msgs[x].getContent();
//System.out.println ("ok");
if(attachment==null)
try
v.addElement(x);
v.addElement(from);
v.addElement(date);
v.addElement(subject);
v.addElement(body);
//System.out.println (v.size());
System.out.println("********* mail "+x+" ***********");
System.out.println("From: "+from);
System.out.println("Date: "+date);
System.out.println("Sub: "+subject);
System.out.println("body: "+body);
System.out.println("Attachment: No attachments......");
System.out.println ("*******************************\n\n");
catch (Exception ex)
ex.printStackTrace();
else
try{
v.addElement(x);
v.addElement(from);
v.addElement(date);
v.addElement(subject);
v.addElement(body);
v.addElement(attachment);
System.out.println("********* mail "+x+" ***********");
System.out.println("From: "+from);
System.out.println("Date: "+date);
System.out.println("Sub: "+subject);
System.out.println("body: "+body);
System.out.println("Attachment: "+attachment.toString());
System.out.println ("*******************************\n\n");
catch(Exception ex1)
ex1.printStackTrace();
// System.out.println (v.size());
catch (Exception ex)
ex.printStackTrace();
catch(Exception e)
e.printStackTrace();
System.out.println (v.size());
return v;
public static void main(String argv[])
new msgshow().show();
Flags flags = m.getFlags();
StringBuffer sb = new StringBuffer();
Flags.Flag[] sf = flags.getSystemFlags(); // get the system flags
String s = "";
for (int i = 0; i < sf.length; i++)
if (sf[i] == Flags.Flag.SEEN)
s = "\\Seen";
System.out.println ("Seen Message");
*/
Similar Messages
-
Mail not receiving incoming mail from gmail account
I have an imac with 10.5 that has suddenly stopped accepting email in one of my gmail accounts, but still gets it from another. I synched my imac with my ibook earlier today. The ibook has the same problem accepts mail from the account that the imac doesn't etc.
Any help solving this problem would be greatly appreciated.
dcHi,
Did you select “Directory Management Service” option, if so, please make sure you configure the Central Administration application pool identity account to have the Create, delete, and manage user accounts right to the container that you specify in Active Directory.
Did you install Exchange server 2003 in your MOSS environment? If so, you should add an SMTP connector in Exchange Server, if you don’t know how to do that, you can post your issue into the following forum:
http://social.technet.microsoft.com/Forums/en-US/exchangesvrdeploy/threads
Also, please check whether your configuration meet the following requirements, If not, correct them and check the effect.
· The application pool account for Central Administration, the logon account for the Windows SharePoint Services Timer service, and the application pool accounts for your Web applications should have the correct permissions to the e-mail drop folder.
· The domain controller running Active Directory has a Mail Exchanger (MX) entry in DNS Manager for the mail server that you plan to use for incoming e-mail.
For more information about how to configure incoming e-mail settings, please refer to the following article:
Configure incoming e-mail settings
http://technet.microsoft.com/en-us/library/cc262947.aspx
Introduction to incoming e-mail
http://office.microsoft.com/en-us/sharepointtechnology/HA100823061033.aspx
Demo: Configure a SharePoint Server 2007 site to receive e-mail
http://office.microsoft.com/en-us/sharepointserver/HA102047921033.aspx?pid=CH101788401033
Enable and configure e-mail support for a list or library
http://office.microsoft.com/en-us/sharepointtechnology/HA100823071033.aspx?pid=CH101215271033
Rock Wang
Rock Wang– MSFT -
Mail - Retrieveing Mail from multiple accounts
I have multiple e-mail accounts, one for each family member (1 primary plus 4 for my kids) and would like to retrieve all e-mails to the same in-box (to keep track of my kids messages). Mail Help instructed to create aliases for my primary e-mail account. I went to Mail>Preferences>Account Information>E-Mail Address and listed the e-mail addresses separated by commas. After saving, then restarting my iBook, Mail will still only retrieve messages from the primary account, not any aliases. Where did I go wrong? Thanks.
iBook G4 Mac OS X (10.4)If all email accounts are provided by the same provider, are the 4 additional accounts alias accounts with the provider?
An alias account to a primary account shares the same user name and password in addition to the same incoming mail server as the primary account.
If each of the 4 additional email accounts require and have a different user name, you cannot create the additional accounts as alias accounts to or with the primary account with the Mail.app or with any email client.
When creating separate accounts in Mail, each account has its own Inbox, Drafts, Sent, Trash and Junk mailbox (when Junk Mail is set to automatic) but you can view received messages by all accounts by selecting Inbox in the mailboxes drawer. When opening Inbox in the mailboxes drawer revealing the account named Inbox mailbox for each account, selecting an account named Inbox mailbox reveals messages received by that account only in the message list. When selecting Inbox in the mailboxes drawer reveals a blended Inbox mailbox for all accounts and the same applies to Drafts, Sent, Trash and Junk in the mailboxes drawer.
Are you aware of Parental Controls included with Tiger?
http://www.apple.com/macosx/features/family/ -
E-Mail won't send my mail from GMail account
My e-mail keeps on telling me that it can't send e-mails from my GMail account and it's the primary account I use for sending e-mails. Please, tell me what do i have to do in order to be able to send e-mails from my Maill app on my iMac?
photo: http://cl.ly/image/2j1s0h2d1H18The error message says that you don't have an outgoing mail server selected. Go to Mail > Preferences > Accounts and select the gmail account in the left hand panel. Next go to "Outgoing Mail Server" :
It should read smtp.gmail.com if you are using pop. If it is blank click on it and it should display whatever outgoing servers you have configured. If the only option you have is to "Edit SMTP Server List" then you need to enter the information as shown below.
These are the standard settings for gmail pop:
You will also need to set password authentication on your outgoing (SMTP) mail as shown below: -
Retrieving mail from POP account folders
I've kept my mail on the server for a while, and have created folders for different subjects. Now I'd like to keep all my mail on the Mac.
Getting the stuff from Inbox is easy, but I can't find a simple way to retrieve the contents of the folders. Is there a way to get Mail to do this, or do I have to empty each folder into Inbox and then retrieve mail?
Thanks
Bob
iMac intel Mac OS X (10.4.8)If this is a POP account, there is no way for Mail (or any other POP client for that matter) to download your mail from the server other than moving it to the server’s Inbox.
-
Cannot get mail from Gmail account on iPhone 4
iPhone 4 just started to receive message that the gmail account has ID and/or Password are incorrect. This is not so as I can go to Goggle Chrome browser and receive email. I have the iOS7 operating system installed. Help...Thanks
Thanks a lot.
Same issue on iPad air. Solved with your suggestion..
Marco -
Import mails from gmail account
I've setup my gmail and it send and recieved just fine but I remember for leopard mail it automatically download all the emails i had in my account into my leopard mail.
but as for the tiger mail, it didn't download all the mails into my mail account in tiger.
is there anyway I can like import all the mails I've got in my account into my tiger mail?First, enable your GMail account as a POP account :
http://gmail.google.com/support/bin/answer.py?answer=13273
Then, configure your Mail account:
http://mail.google.com/support/bin/answer.py?answer=13275
Hope that helps (worked for me) -
Can't delete mail from gmail account
I am using Apple mail and it is synced with a gmail. When something from the gmail shows up in my inbox and I delete it, it goes to a folder called all mail. When I delete something from all mail it reappears there ten minutes later. Any suggestions?
You might have better luck asking this in the Mail forum.
-
Help with retrieving emails from Gmail into Mail
Help! I'm helping my mom with her computer and her hard drive died (not backed up of course). She has a new hard drive now and I am importing her emails from her Gmail account into Mail. It worked great importing all the emails that she has since July 15th (the last time she retrieved mail from her Gmail account). If I go into Gmail through Safari I can she has hundreds more emails prior to this date still on their servers but they didn't download into Mail. I presume this is because Gmail knows they have been downloaded once before (to her old dead hard drive), but how do I get around this so all of her emails can be imported into Mail? The only copies are on the Gmail servers.
Thanks in advance for your help,
ScottOkay, then let's try this:
1. Quit Mail.
2. Go to Home/Library/Mail and remove (don't copy and don't empty the Trash) the POP mailbox.
3. Go to Home/Library/Preferences and remove the com.apple.mail.plist file.
4. Restart Mail, setup your POP account again and it should connect to Gmail and download all the messages. If it does, then you can delete the file and folder you previously removed. -
Well, that's it really. I need to send an e-mail from an account for apple mail to retrive new incoming mail.
This has started happening since I upgraded to Mavericks. It's very temperamental. Some days it needs massaging to get my mail (as per above), other days it works like a well-oiled machine.
Any thoughts anyone?If no one replies here try the Java Mail Forum:
http://forum.java.sun.com/forum.jspa?forumID=43 -
How can I move mail from Gmail to another account?
Mail.app in Mavericks is incompatible with Gmail. I use Gmail. I have about 2GB of mail, most of it in a few dozen archive folders, stored on Gmail, and (I think) duplicated locally on my Mac Mini.
I think my best recourse is to switch to an email service provider that conforms to the IMAP standard (which Gmail does not). Assuming I find one, I will have both accounts, Gmail and the new one, in Mail.app. How can I move the mail from Gmail to the other account?
In Mail.app in Mavericks, All Mail must be marked to show as a folder, and when I move a message from a folder in Gmail it will still be in the All Mail folder.
When all folders are empty, including the Inbox, can I be sure that every message has been moved to the new account, even though every message is still in the All Mail folder?Mail.app in Mavericks is incompatible with Gmail. I use Gmail. I have about 2GB of mail, most of it in a few dozen archive folders, stored on Gmail, and (I think) duplicated locally on my Mac Mini.
--> mine's working fine. I know there are issues, but it should work
I think my best recourse is to switch to an email service provider that conforms to the IMAP standard (which Gmail does not).
--> yes, it would be nice if they adhered to standards. That said, mine works great. So far.
Assuming I find one, I will have both accounts, Gmail and the new one, in Mail.app. How can I move the mail from Gmail to the other account?
--> If all you want to do is keep your history, make a local folder on your mac and drag all the mail messages there (both se4nt and incoming). I am not sure what will happen if you later drag those into the new Xmail account
When all folders are empty, including the Inbox, can I be sure that every message has been moved to the new account, even though every message is still in the All Mail folder?
--> Dont look in "all mail". Open your inbox and look at each individual inbox.
Good luck,. But first, try to fix your account.
Grant -
I just opend an account with MAIL.
The trasnfer of my emails worked, but all emails (received and sent ones) from my Gmail account appear in the inbox of mail.
All sent ones appear only in the sent box, if I sent them from the mail programm. If I sent any email from my Gmail account the always be transferd all in the inbox of the mail programm.
I don´t havy any clue what to do. I already checkes all settings - I guess...
I need assistance - please!
p.s. it´s a pop account, if this matters...This is intended behavior with Gmail POP access,
however weird it may seem. Gmail POP access does not
work as a normal POP mail server should (points 4 and
5 below are relevant to your "problem"):
1. Messages downloaded by any conventional POP
mail client are marked as downloaded at the
server, and no longer available to either the
same or any other mail client.
2. To make already downloaded Gmail messages
available for POP access again, you must log into
your Gmail account with a web browser and re-enable
POP downloading for all your messages, which will
cause everything (and I mean everything) still
there to be downloaded again.
3. Any "Remove copy from server" account settings in
Mail > Preferences > Accounts > Advanced have
absolutely no effect on the messages stored on the
server. The reason is that, after being downloaded,
those messages are no longer available to any mail
client, not even to the same client that has just
downloaded them, not even for deleting them or
checking whether they are still there.
4. Messages created and sent using the web interface
will be downloaded by your POP mail client as if they
were incoming messages. You can set up a rule in Mail
to automatically route those messages to the
appropriate Sent mailbox (or to any other mailbox for
that matter) if that's what you want. Although this
may seem weird, it's good because it allows archiving
all messages locally in Mail, regardless of how they
were sent -- as long as you don't access the same
Gmail account with more than one mail client, that
is.
David, thanks for your reply. Yes, point 4 seems to be relevant for my problem. How does it work to "set up a rule in Mail to automatically route those messages to the Sent Mailbox" (in Mail). I want my messages downloaded from my Gmail account to be ordered in the Inbox and Outbox in Mail (like it is ordered in Gmail). The messages which I sent from the gmail account should not appear in the Inbox of Mail...
5. Messages created and sent using a POP mail client
such as Mail are also treated as if they were
incoming messages for POP purposes, just as in 4.
What prevents them from being downloaded is that
Gmail marks them as already downloaded immediately.
They would, however, be downloaded if Gmail settings
were changed as described in 2 above. -
Mail hangs upon retrieving last mail from POP account
Hi,
I have a problem with retrieving mail from a POP account. Mail seem to hang after the last new mail has been retrieved from the account. E.g, the activity viewer shows "Fetching 7 of 7", the progress bar indicates that all mails have been retrieved, but never completes. Pressing the Stop button next to the progress bar does not have an effect. Mail then indefinitly hangs in the "STOPPING" phase. In that state I cannot retrieve mails for other accounts, either. I have to force quit Mail.
Has anyone experiences similar problems and found a solution?
Thanks,
Sascha
iMac G5 Mac OS X (10.4.8) Mail Version 2.1 (752/752.2)Does your account have webmail capability? If so, log into your account that way, and deal with the offending message.
-
How Can I Use a Gmail Account with Multiple Email Addresses in iPhone Mail?
So I have a Gmail account with 4 POP accounts that it checks... Is there a way to get "Reply From" from multiple addresses?
I've tried the following sites... No luck with iOS 5...
http://email.about.com/od/iphonemailtips/qt/gmail_multiaddr.htm
http://modernerd.com/post/535350679/solved-gmail-ipad-iphone-and-multiple-fromBy setting up your GMail account to forward emails to your iCloud email account address.
You won't be able to reply from your Gmail address from within iCloud though. -
I formerly had an iPhone 3 with my iTunes account/music on it. I've recently purchased an iPhone 5s. I no longer have the iPhone 3. Is there any way to retrieve music from my account and put on my iPhone 5s?
Yes. Sign in to the iTunes Store with the same Apple ID you used to buy the music in settings on the phone.
Then tap on "purchased" in the iTunes app on the phone and download the music to your new iPhone.
Maybe you are looking for
-
Addition of 0MAT_PLANT to a cube
Hi, I have the following requirement. I need to create a report on a cube where I need to display a field called Import Code of a material This Characteristic is an attribute of 0MAT_PLANT InfoObject. The cube has 0MATERIAL and 0PLANT. But it does no
-
Hi All, We want to create a report on Account so that it will fetch a detail of all the person's who last updated the Account. This report will help us to keep a track of all the person who had updated a particular account. Thanks.
-
This is the way Avant browser works by default. So if I am gonna change to Firefox this is an issue for me to work without doing any extra clicks...
-
Blue dot arrow in box VS NO blue dot arrow in box. Explain, please!
WHAT I SEE IN SAFARI: Some pages have the "Return to Main Site Menu" text line IN A BOX, but some other pages have that text line NOT IN A BOX. Specifically: "Photos — Past" has "Return to Site Menu" IN A BOX. "Photos — Present" has "Return to Site M
-
Earlier today i upgraded my system with pacman. I didn't see exactly what was upgraded, but whatever it was must have been buggy and broke xfce4. Everything seemed to be fine after the update (i hadn't rebooted yet) until i tried to download somethin