Checking mail ONLY when theres new mail

Hello! :)
I have a program that checks for new mail, parses data in the new mail, sleeps for one minute, and then repeats this whole process infinately. I think it'd be more effective if I only check mail when there's NEW mail, not every minute....
How do I do this?
Many Thanks!
Liam

Hi... just one last question... I tried using MessageCountListener but it somehow DOESN'T recognize when there's new mail (the messagesAdded method isn't called). I think I might have added the MessageCountListener wrong, but I can't figure out why.
Also, I still use a "while" loop, just so that my program won't end, and this is eating up memory! :(
Anyway, this is some of my code...
public class MAPI implements MessageCountListener
     // some variable declarations
     MAPI() throws Exception
      Properties props = new Properties();                         
      Session session = Session.getInstance(props, null);               
      Store store = session.getStore("imap");                      
      store.connect(host, username, password);
      Folder folder = store.getFolder("INBOX");
      folder.open(Folder.READ_WRITE);
      folder.addMessageCountListener(this);
      while(true)
    public static void main (String args[])  throws Exception
       new MAPI();
    public void messagesAdded(MessageCountEvent e)
       System.out.println("You've got mail!");
    public void messagesRemoved(MessageCountEvent e) {}
}

Similar Messages

  • How to program shift register to read only when a new user is detected from user?

    Hi,
    I'm currently developing a program for position control in labview. The program is quite simple, whereby user will input the distance that he wants the table to be in the labview program, and labview will send signal to move a motor that will turn a ball screw to move a table horizontally to the targetted position. The criteria is that the profile of the motor depends on the distance it needs to move, whether a two-phase (acceleration and deceleration) or three-phase (acceleration, constant velocity, deceleration) to reach the target position.
    The problem occurs when the user wants to enter a new position (second input) for the table, as the input by user is position the table needs to be but the input required to determine which profile the motor follows depends on the distance that the table will move to get to the targetted position. Therefore, I would need a function to store the input by user temporarily, and recall it only when a new input from user is detected. By this, I would be able to use the difference of the input (input [n+1] - input[n]) and feed it to determine which profile the motor follows and the input by user can be kept as the position he wants the table to travel to (to compare with encoder).
    I thought of using shift registers to do this, but I am not able to make it to perform the deduction ([n+1] - [n]) only when it detects a new input. When i try using shift register, it travels to the targetted position, and one it reaches it will travel back to the original position. For example, when a user input 90, it means the table needs to move to point 90. As the shift register is initialized to 0, it will move to point 90 (90-0 = 90) but upon reaching 90, the shift register sends a signal of 90 (90-90 = 0) and the table returns to it's initial position.
    Is there any way that I can delay the reading of shift register only when a new input is detected or is there another way for me to achieve what i want?
    I've tried searching the discussion forum and ni website but couldn't find similar problems. Thanks for your help in advance.
    Solved!
    Go to Solution.

    Hi,
    I've managed to get what I needed by using a shift register + event structure as suggested by Adnan. However, I face another problem after implementing SR+event. I've attached two files, first the original program and second the updated program using SR + event. (it's only the jpg file as I've forgotten to save the labview program, will upload the program by tomorrow.
    In the original program, I have an elapsed time that is able to run continuously when I run the program. In the updated program, my elapsed time don't seem to run continuously when I run the program (as shown by elapsed time indicator). I need the elapsed time to run continuously as a input to calculate my motor profile.
    I suppose this is caused by the introduction of the event structure, will adding a case structure to wrap the event structure solve the problem or is there another way to get pass this. Appreciate if someone could drop me a pointer or two.
    Thanks
    Attachments:
    Mar 16 - continuous elapsed time.png ‏12 KB
    Mar 16 - elapsed time not continuous after introducing shift register + event structure.png ‏17 KB

  • What does the message "Commit can be issued only when there are no requests awaiting responses" mean ?

    Can someone explain what this message is, and what the reason could be for
              the java.lang.IllegalStateException.
              When such an error is encountered, how can I find out what the
              "RepliesOwedMe" are. The complete exception is as follows
              Any quick hint is greately appriciated
              Thanks
              asankha
              <Sep 6, 2001 12:49:18 PM GMT+06:00> <Error> <EJB> <Exception during commit
              of transaction transactio
              n=(IdHash=8297169,Name = [EJB
              CActionBeanImpl.execute()],Xid=3:c56b8ee8f6114598,Status=Active,numRep
              liesOwedMe=2,numRepliesOwedOthers=0,seconds since begin=0,seconds
              left=29,ServerResourceInfo[weblogi
              c.jdbc.jts.Connection]=(state=suspended,assigned=none),SCInfo[myserver]=(sta
              te=active),properties=({
              weblogic.transaction.name=[EJB CActionBeanImpl.execute()],
              weblogic.jdbc=t3://10.2.1.133:7001, weblo
              gic.debug.DebugContext=weblogic.utils.DebugContext@662250})):
              java.lang.IllegalStateException: Commi
              t can be issued only when there are no requests awaiting responses.
              Currently there are 2 such reque
              sts. xid = 3:c56b8ee8f6114598, status = Active
              at
              weblogic.transaction.internal.TransactionImpl.throwIllegalStateException(Tra
              nsactionImpl.
              java:1272)
              at
              weblogic.transaction.internal.TransactionImpl.checkIfCommitPossible(Transact
              ionImpl.java:
              1206)
              at
              weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransaction
              Impl.java:162
              at
              weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:201)
              at
              com.edocs.wb.web.action.CActionBeanEOImpl.execute(CActionBeanEOImpl.java:37)
              at CeaMarketMainServlet.doGet(CeaMarketMainServlet.java:185)
              at CeaMarketMainServlet.doPost(CeaMarketMainServlet.java:312)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              :213)
              at
              weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
              ntext.java:12
              65)
              at
              weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
              :1631)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              >
              

              This means that the transaction initiator has not received replies for some of
              the transactional requests when the transaction commits, i.e. the checked transaction
              behavior is violated. WLS TM enforces checked transaction behavior to make sure
              that all work done in the transaction context will be completed before transaction
              is committed. If it cannot make such guarantee due to outstanding replies, it
              aborts the commit right away.
              Currently, there is no provisions for dumping the requests whose replies are still
              pending.
              I would suggest you report to BEA support: [email protected]
              Regards,
              Priscilla
              "Asankha C. Perera" <[email protected]> wrote:
              >Can someone explain what this message is, and what the reason could be
              >for
              >the java.lang.IllegalStateException.
              >
              >When such an error is encountered, how can I find out what the
              >"RepliesOwedMe" are. The complete exception is as follows
              >
              >Any quick hint is greately appriciated
              >Thanks
              >asankha
              >
              ><Sep 6, 2001 12:49:18 PM GMT+06:00> <Error> <EJB> <Exception during commit
              >of transaction transactio
              >n=(IdHash=8297169,Name = [EJB
              >CActionBeanImpl.execute()],Xid=3:c56b8ee8f6114598,Status=Active,numRep
              >liesOwedMe=2,numRepliesOwedOthers=0,seconds since begin=0,seconds
              >left=29,ServerResourceInfo[weblogi
              >c.jdbc.jts.Connection]=(state=suspended,assigned=none),SCInfo[myserver]=(sta
              >te=active),properties=({
              >weblogic.transaction.name=[EJB CActionBeanImpl.execute()],
              >weblogic.jdbc=t3://10.2.1.133:7001, weblo
              >gic.debug.DebugContext=weblogic.utils.DebugContext@662250})):
              >java.lang.IllegalStateException: Commi
              >t can be issued only when there are no requests awaiting responses.
              >Currently there are 2 such reque
              >sts. xid = 3:c56b8ee8f6114598, status = Active
              > at
              >weblogic.transaction.internal.TransactionImpl.throwIllegalStateException(Tra
              >nsactionImpl.
              >java:1272)
              > at
              >weblogic.transaction.internal.TransactionImpl.checkIfCommitPossible(Transact
              >ionImpl.java:
              >1206)
              > at
              >weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransaction
              >Impl.java:162
              >)
              > at
              >weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:201)
              > at
              >com.edocs.wb.web.action.CActionBeanEOImpl.execute(CActionBeanEOImpl.java:37)
              > at CeaMarketMainServlet.doGet(CeaMarketMainServlet.java:185)
              > at CeaMarketMainServlet.doPost(CeaMarketMainServlet.java:312)
              > at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
              > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              > at
              >weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              >:213)
              > at
              >weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
              >ntext.java:12
              >65)
              > at
              >weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
              >:1631)
              > at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              >>
              >
              >
              

  • Process only when there is a change in source file

    Hi Experts,
    My scenario is File to File.
    Requirement is, source file need to be picked up only if there is change in the data.
    Please guide me the approach for this.
    Thanks
    Kishore

    Hi
    I have also had similar problem and gone thru ur reply.
    one blog was telling about accessing new files but not about new data in same file.
    and can you please explain about the other blog RFC calls from Adapter modules...the Web Service Way . i am not sure about this approach to achieve my goal.
    Kishore..if you found solution for ur approach pls let me know.

  • Audio problems on new Alienware 17 but only when there's no internet

    Everytime I used my laptop to watch some videos in the train I had issues with the audio: sound randomly disappearing and minor distortions from time to time. What I found was very surprising: turning on games on Steam (so far it's Hammerwatch and Risen 2) fixed the problem, then I could turn off the game and keep watching videos without problems. Tried figuring out the problem at home and the problems disappeared when I would turn on the wifi... So far I have no idea what is the root of the problem, but it would be great to fix this annoyance.

    Hi,
    my MBP 13" Mid 2010 running 10.6.4. has similar problems. I like to use it closed lid connected to an external display with apple usb keyboard. In closed lid mode airport connection fails several times or I do get a poor connection, e.g. one or two curves in the airport menu bar icon with significant lower connection speeds. I do connect to a airport extreme n station with does its job rock solid. as my wife uses a two year old macbook and I have got an G4 with a sonnet airport card running both without problems even from a greater distance in our home it seems to me that the macbook pro has serious problems operating with the internal wifi antenna in closed lid mode, maybe due to shielding from the lid?
    Has anybody experienced the same problem or successfully found a way to solve this problem? When using open lid mode wifi problems never occurred, but that's not the preferred option for my desktop table.

  • Photoshop CS4  shuts down only when creating new project.

    I've had CS4 web premium since nov. 08 and everything worked fine until the most recent update from adobe.
    I ONLY have this problem with Photoshop cs4: when creating a new project after selecting the aspects (name, width, hight, etc.) when you press ok it shuts down and no error is given as to why it shut down, it just does.
    opening documents that had been created prior to the last update isn't a problem, I'm able to do everything Photoshop cs4 has to offer.
    I can also open a file started in another program and edit them in PS CS4 (ie: fireworks , or AI).
    but for some reason if I want to start a project in photoshop it just shuts down, never used to happen. any clues? any one else have a similar problem and know how to fix this?
    running on windows XP

    I think you mean a new docuement - Photoshop doesn't have "projects".
    Photoshop shouldn't "shut down" - there should be some message about a crash.
    And the most likely causes at that point are OpenGL (try turning it off in prefs) and your default printer driver (try changing default printers).

  • How can I play the current slide only when there is an audio recording?

    Hi,
    I have a 10 slide presentation where I am recording audio one slide at a time. If I have the current slide selected and click play, Keynote plays from the beginning of the presentation.
    Is there a way to have Keynote playback only the slide selected when audio is recorded?
    Thanks,
    humbucker

    humbucker237 wrote:
    Thanks! That really helped. Why does the audio recording cause so many issues when it's done using Keynote?
    humbucker,
    I don't really have an answer for that. It usually boils down to complications when all combinations of possible uses are considered. One scenario may seem a no-brainer taken by itself, but not when other options are in play.
    I was responding to your specific question about Quicktime recording. You could also use Garage Band, Audacity and the like, of course. Quicktime is just so much easier than any other option that I'm aware of for making short, simple, recordings.
    Jerry

  • Duplicate Check Function in CRM when creating new BPs?

    Hi
    Three questions:
    1. does anyone know if there is some standard way in CRM (we are on CRM5.0) to enable a duplicate check to happen when a new business partner is created - one that will warn that a similar BP already exists when the user goes to save (or even better, when part way through creation)? I have already looked into using the data cleansing cases in CRM, which is ok for existing duplicate records, but doesn't help with stopping them being created in the first place.
    2. Is there a standard function/report available that will go through the database and identify any potential duplicate records? Or, does anyone know of some standard function calls/bapis etc that can be used by our developers to design something to do this for us?
    3. Failing the above two, are there any recommendations out there for 3rd party add-ins for address/duplicate checks?
    Any insight would be most gratefully received!
    Regards
    Cara

    Hi Cara
    SAP Business Address Services (BAS) is used for maintaining BP address data.
    You can maintain any number of addresses for each business partner. One address per business partner is always flagged as being the standard address. You can define address usages by assigning the different addresses to the relevant business processes.
    Postal data and information on different communication types, such as phone numbers, fax numbers and e-mail, can be assigned to the address. If you have only the name and the (mobile) phone number of a business partner but you donu2019t know the address, you can create a BP with this address-independent communication data.
    Now Answer to your question
    A postal validation for the postal code, the city and the street can be carried out by checking against the SAP Regional Structure. You can also use external software for postal validation, checks for duplicates, and error-tolerant searches. (For more information, please see SAP Note 176559.)
    The following are examples of possible checks:
    Postal codes, cities and streets, and combinations of all of them are checked for consistency. During the check, missing elements are added. For example, if you enter only the city, the postal code is added.
    When you create and change a business partner, several phonetically similar, existing BPs are proposed for comparison purposes.
    This prevents you from creating the same partner more than once.
    Please let me know if this answered your questions.
    Regards
    Dinesh

  • Can't Check Mail Manually

    I searched all over for the answer but can't find it, so i am hoping i hasn't been posted before. 
    Basically I want to only have Mail check my mail when I ask it to.  For years I had it set up to check every minute and I was happy with that.  But in the interest of efficiency, I want to only check my mail when I personally click on the "Get Mail" Button on the top left of the app. 
    I have gone into the preferences and have set the "Check for new messages" to Manually but it isn't working.  I am not running Lion yet, but this was also the same issue in Tiger and Leopard years ago.  Now I am trying to fix it for good in Snow Leopard in both my '07 macbook and brand new mac mini. 
    Is anyone else running into this problem and having the messages still come through every minute even though you have set the preferences correctly (to manually) and restarted your computer, etc. 
    Just so you know, I also tried "hourly" and the messages still come through every minute or really every time I get one.  Thanks for the help.

    Go to Mail > Preferences > General and go to "Check for new messages:" and change it to "Manually". It should check email only when you click the Get New Messages button.
    There is an outbox, but it's not a place to store emails like in Outlook. If you want to write an email but not send it, write the email (you don't have to address it if you don't want to), and go to File > Save. This will save the email in the DRAFT mailbox. So you definitely don't have to send what you write right away--Creating a Draft is the way to go.

  • How can I force a database trigger to fire only if there is an update not when insert

    Hi
    Could you help me please. I have a data base trigger that need
    to fire only when there is an update in some columns in a table
    But the trigger is firing eventhough they only do an insert.
    here is the begining of the trigger.
    create or replace trigger alpha_HZ_LOCATIONS_AUR
    after update of address1,address2,city,state
    ,postal_code,county,province,country,attribute20
    on hz_locations
    for each row
    DECLARE
    v_cust_account_id hz_cust_acct_sites_all.cust_account_id%type;
    v_cust_acct_site_id hz_cust_acct_sites_all.cust_acct_site_id%
    type;
    v_org_id hz_cust_acct_sites_all.org_id%type;
    -- cursor; all sites for this customer address
    cursor sc is
    select
    s.site_use_id site_use_id
    ,s.attribute15 frk_addr_number
    from
    ra_site_uses_all s
    where s.address_id = v_cust_acct_site_id
    and s.site_use_code in ('BILL_TO','SHIP_TO');
    rowcnt number;
    v_system_code varchar2(15);
    v_ora_cust_num varchar2(30);
    v_frk_cust_num varchar2(15);
    v_insert_update_flag varchar2(1);
    BEGIN
    v_insert_update_flag := 'U';
    -- get cust_acct_site_id (address_id)
    begin
    select acct_site.cust_account_id,
    acct_site.cust_acct_site_id, acct_site.org_id
    into v_cust_account_id, v_cust_acct_site_id, v_org_id
    from
    hz_party_sites party_site
    ,hz_cust_acct_sites_all acct_site
    where acct_site.party_site_id = party_site.party_site_id
    and party_site.location_id = :new.location_id;
    Thank you much
    alpha

    Thanks for the response. My trigger is firing when I update the
    table trough a form. Also when the uses go into the oracle apps
    and create a new customer they get an error saying
    ora-01403 no data found
    ora-06512 at'the trigger name' and gives line number
    ora-04088 error during execution of trigger.
    Note: and I looked trigger it's really ok.
    If you can please help

  • Is there a setting where a text frame (border, color, etc) will be visible only when it has content?

    I use data merge a decent amount, often when I am quick prototyping decks of cards for games. (Talk about an awesome tool for quickly cranking out a hundred different cards). I was wondering if it possible to have a text frame style (say a 1pt solid black border, or a yellow background etc.) appear only when there is text inside that frame.
    For example the cards need to have different combinations of text on each one. The lower part of this particular card has 30 data field placeholders (15 text frames and 15 graphic frames) that are linked back to my .txt file with data merge. (In the first image below, all 30 data fields have data in them, the other images only have some data applied) The text frames hold the two letter code, the graphics frame is basically a .png of either a rectangle or oval which is on a layer behind the text frame.
    It would be awesome if a text frame border was only present when there was content in the text frame. That way I could eliminate all of the graphics frames in this particular case. Is this possible? I knid of don't want to ask this, but is it possible through scripting with some sort of conditional statement? (Iknow very little about scripting except that it exists to do certain tasks on a as needed basis)
    I'm using InDesign CC on Mac OSX 10.7.5
    Thanks!
    go-dog-go

    There's no one solution. Depends on the context.
    When we know what we have and where we want to go, everything becomes simple ...
    In your case, the solution I prefer is that with grep styles.
    Why? because it is truly magical.
    The beginning...
    All you finally have to do in the data file is inserting columns of calculation. We can talk later.
    This solution with grep style is very simple to define. In ID and Excel (for instance). Because I know how to do. I understand It could be not so simple for another person.

  • GRC 5.3: CUP asks to perform risk analysis even when there are no risks in request

    Hi All,
    We recently upgraded from GRC 5.3 SP13 to SP22.
    The one issue which we are facing after upgrade is that now CUP is forcing approvers to do Risk Analysis, even when there are no risks in the CUP Request, that is Risk Tab is Green.
    Previously approvers were able to approve requests without doing risk analysis, if there were no risks in the request.
    CUP used to force them to do risk analysis only when there were risks associated with requests.
    But now, it is forcing approvers to perform risk analysis, even if there are no risks, i.e. approvers are not able to approve requests without any risks without doing risk analysis.
    Please advise.
    Thanks
    Aditi

    Hi,
    Can you check if any change is made in Configuration -> Workflow -> Stage -> Approvers
    Regards,
    Claudio

  • How to run TCP/IP Tx in cRIO vi only when value changes?

    My design uses NI's TPC-2006 as the user interface for a cRIO-based product.  I use TCP/IP to exchange data between the TPC-2006 and cRIO.  My code causes the TPC to lock up after a variable number of minutes, typically about 10.  The OS is completely locked and requires a power cycle to recover.
    Based on the theory that the TPC-2006 is not keeping up with the TCP/IP packets sent by cRIO, I want to try configuring cRIO to transmit only when it has something new to say.  The event structure that I use for the TPC-2006 won't work on cRIO.  Can anyone out there suggest another approach?
    Jeff
    Climbing the Labview learning curve!
    Sanarus Medical
    Pleasanton, CA

    Hi Jeff,
    The simplest way to reduce transmission overhead in this scenario would be to encase your existing TCP/IP routine in a case structure that only executes if the data element you're interested in is not equal to its last value (stored in a shift register).  This shouldn't add much in the way of computational overhead on the RT side, but should reduce the flood of data if the value doesn't change very often.  Keep in mind also that if you have LabVIEW 8, you can use Shared Variables to send the data over your tcp/ip connection only when a new value is written to the variable - this may meet your needs just as well.
    Cheers,
    Matt Pollock
    National Instruments

  • Random power shutdowns when there is high performance

    Hey guys
    I am using a refurbished Macbook purchased in late 2011, its running on Mac OS-X version 10.6.8.
    I had to change my laptop's old hard drive to a new one after I experienced the 'grey screen of death' two weeks ago. I also bought a new battery for my laptop as the old one was starting to go bad.
    Even after that, I am experiencing random shutdowns. This happens only when there is high performance involved - when browsing the Internet and I have a lot of Safari tabs open, or when I am transferring files from my portable hard disk drive.
    The guy at the shop says the fans are working fine, even though iStat says the fans are running at 0 RPM.
    Any suggestions?

    its most likely shutting down to prevent the mac from overheating and getting damaged.  Since this only happens during high performance.

  • Display 'No Data Found' when there is inv data but still there is xml data

    Hi,
    I am converting an rdf to BI publisher. The issue is when there is no detail (inv) but still there is still xml data , due to which the report is getting printed with the skeleton template and blank details(inv).
    I need to avoid printing the report out if there is not inv detail even though there is xml data. or atleast show 'NO DATA FOUND' msg. and print the report output only when there is inv data.
    Any help is greatly appreciated.
    sample XLM generated when there is inv data:
    - <ARXCBI>
    - <LIST_G_SETUP>
    - <G_SETUP>
    <COMPANY_NAME>GL SOB</COMPANY_NAME>
    <FUNCTIONAL_CURRENCY>USD</FUNCTIONAL_CURRENCY>
    <COA_ID>23456</COA_ID>
    <SET_OF_BOOKS_ID>1</SET_OF_BOOKS_ID>
    <LIST_G_SITES />
    <REPORT_NAME>Billing Invoice</REPORT_NAME>
    <SUB_TITLE />
    </G_SETUP>
    </LIST_G_SETUP>
    <RP_COMPANY_NAME>GL SOB</RP_COMPANY_NAME>
    <RP_REPORT_NAME>Billing Invoices</RP_REPORT_NAME>
    <RP_DATA_FOUND />
    <RP_SUB_TITLE />
    <R_DEFAULT_COUNTRY>US</R_DEFAULT_COUNTRY>
    <R_DEFAULT_COUNTRY_DESC>United States</R_DEFAULT_COUNTRY_DESC>
    <T_REPORT_TOTAL />
    <RP_COUNTER />
    <INV>Invoice</INV>
    <CM>Credit Memo</CM>
    <ADJ>Adjustment</ADJ>
    <XREV>Reverse Cross Site Credit Memo</XREV>
    <XAPP>Apply Cross Site Credit Memo</XAPP>
    </ARXCBI>
    Thanks!

    Hi Srini,
    Now I am running into another problem. When there is no detail data it displays 'No data found' as expected in the report output. But is there any way to restrict the print option (avoid wasting the paper) to just display 'No data found' in the output but not to print the output only in this case.
    I really appreciate any help!

Maybe you are looking for