locked
how to receive email by program RRS feed

  • Question

  • hi

    in outlook we can send email by program using mailItem.send(); my question is:

    Is there the same function for receiving email.

    because in my project i need to receive email by program.please tell me if you know

    thanks a lot

    Tuesday, June 1, 2010 5:00 AM

Answers

  • Hello John,

    You can call Application.Session.SendAndReceive() function to initiates immediate delivery of all underlivered messages submitted in the current session, and the immediate receipt of mail for all accounts in the current profile.

    http://msdn.microsoft.com/en-us/library/bb175104(office.12).aspx

    http://msdn.microsoft.com/en-us/library/bb175374(office.12).aspx

    Is this what you are looking for?

     

    Best regards,

    Ji Zhou

    Microsoft Online Community Support


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Proposed as answer by Sue Mosher Tuesday, June 1, 2010 11:56 AM
    • Marked as answer by John83 Zheng Tuesday, June 1, 2010 4:24 PM
    Tuesday, June 1, 2010 7:15 AM
  • One approach is to walk the ActiveExplorer.CommandBars hierarchy in order to locate the command on the Tools menu that will download a particular account. (This won't work in Outlook 2010.)

    Another would be to create a new Send/Receive group just for the particular account, return it from the Namespace.SyncObjects collection, and call its SyncObject.Start method.

    • Marked as answer by John83 Zheng Tuesday, June 1, 2010 4:25 PM
    Tuesday, June 1, 2010 3:58 PM
  • There's already an example in the Outlook Developer documentation: http://msdn.microsoft.com/en-us/library/aa219364.aspx
    • Marked as answer by John83 Zheng Tuesday, June 1, 2010 8:59 PM
    Tuesday, June 1, 2010 6:11 PM

All replies

  • Hello John,

    You can call Application.Session.SendAndReceive() function to initiates immediate delivery of all underlivered messages submitted in the current session, and the immediate receipt of mail for all accounts in the current profile.

    http://msdn.microsoft.com/en-us/library/bb175104(office.12).aspx

    http://msdn.microsoft.com/en-us/library/bb175374(office.12).aspx

    Is this what you are looking for?

     

    Best regards,

    Ji Zhou

    Microsoft Online Community Support


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Proposed as answer by Sue Mosher Tuesday, June 1, 2010 11:56 AM
    • Marked as answer by John83 Zheng Tuesday, June 1, 2010 4:24 PM
    Tuesday, June 1, 2010 7:15 AM
  • hi

    thank you for your answer, and your answer works for me

    i have and other question. i have 3 email account in outlook. but i just want to receive email in just one account.how can i specify the account used to receive emails by program in above question.

     

    thanks

    Tuesday, June 1, 2010 3:45 PM
  • One approach is to walk the ActiveExplorer.CommandBars hierarchy in order to locate the command on the Tools menu that will download a particular account. (This won't work in Outlook 2010.)

    Another would be to create a new Send/Receive group just for the particular account, return it from the Namespace.SyncObjects collection, and call its SyncObject.Start method.

    • Marked as answer by John83 Zheng Tuesday, June 1, 2010 4:25 PM
    Tuesday, June 1, 2010 3:58 PM
  • thank you for your quick answer.

    can i hold the program until the email is completely received. because sometimes if the email is big or the network problem, the unread email won't show intermediately,and i will use the data in the email for another program.

     

    is there any way to tell if  the receiving function is done?

     

    thank you

     

    Tuesday, June 1, 2010 4:30 PM
  • If you use the SyncObject approach, yes, you can wait for completion of the send/receive process, which will fire the SyncObject.SyncEnd event. 
    Tuesday, June 1, 2010 5:15 PM
  • hi

    can you give me a simple example for that

    thanks so much

    Tuesday, June 1, 2010 5:58 PM
  • There's already an example in the Outlook Developer documentation: http://msdn.microsoft.com/en-us/library/aa219364.aspx
    • Marked as answer by John83 Zheng Tuesday, June 1, 2010 8:59 PM
    Tuesday, June 1, 2010 6:11 PM
  • thank you

    C#

    app.Session.SyncObjects[1].SyncEnd += new Microsoft.Office.Interop.Outlook.SyncObjectEvents_SyncEndEventHandler(ThisAddIn_SyncEnd);

    Tuesday, June 1, 2010 8:59 PM