[Ruby] Fetching Emails from Microsoft Outlook

Hi Folks,

Hope everyone is fine and doing good. In this article of mine, I am going to narrate, how you can fetch Emails from your Microsoft Outlook account. I am only going to cover ‘Inbox‘ here. However, the scope of library (Gem) is very vast and you can customize this as per your need.

PREREQUISITE:

  • Ruby
  • ViewPoint Gem: gem install viewpoint

For Debugging, I am using viewpoint/logging/config

Hope this helps someone! Keep in touch and Happy Coding 🙂

Puneet

Advertisements

11 thoughts on “[Ruby] Fetching Emails from Microsoft Outlook

  1. If you’re willing to fetch all unread mails, below code snippet will help

    unread_items = inbox.unread_messages
    p items[0].body.inspect

    If you wish to mark all/single unread message to read, below code snippet will do so:

    unread_items[0].mark_read!(read = true)

  2. Anish

    I tried the code above ,getting the following error : Request URI must have schema. Possibly add ‘http://’ to the request URI?

    at mailbox = cli.get_folder_by_name(‘inbox’).
    Can you please suggest.

    1. Typically end_point URL should start with HTTP or HTTPS. For e.g.:
      end_point = ‘https://YOUR_EXCHANGE_DOAMIN/excahnge.asmx’
      You can try hitting end_point URL into your browser and in return you’ll receive XML. Let me know, if this helps.

  3. Anish

    Thanks Punnet for the prompt reply.
    I am using end_point as described by you above and getting an xml response in browser.
    But as I can see in that response there is no method named : get_folder_by_name.
    But there are other methods like GetFolder etc. Can I use these Soap methods to get the details.

    And it’s giving me timeout error at the point : inbox = cli.get_folder_by_name ‘Inbox’
    in the code.

  4. Anish

    The exact error I am getting is :
    Couldn’t evaluate:cli.get_folder_by_name ‘Inbox’ Unable to read information in the specified timout [20s]

  5. Anish

    I am using viewpoint (1.0.0) version.
    I am not able to fetch any folders using folders = cli.folders
    I am getting the following error in folders = cli.folders:
    {StandardError} Timeout:evaluation took longer than 10 seconds.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s