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
https://gist.github.com/puneetpandey/26035213128e5bc535dc
Hope this helps someone! Keep in touch and Happy Coding 🙂
Puneet
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)
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.
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.
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.
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]
Make sure what all folders are there using: folders = cli.folders and let me know, if there is any folder with the name ‘Inbox’ also which version of viewpoint you’re using?
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.
I am concerned Anish, that you’re able to connect with exchange point! Because looks like this is issue with your endpoint
And my ruby Version is : ruby 2.0.0p481 (2014-05-08) [i386-mingw32]
Can this be a proxy issue. If Yes how can I set the proxy using ViewPoint.
Hi I am trying to automate outlook in ruby with viewpoint. How do I find the server address for http://www.live.com or mail.live.com? Can you please help?
Hi puneeth, I am getting the exception ” Timeout: evaluation took longer than 10 seconds.” when used the command “inbox.items_between startTime, endTime”
can you help me on this if you have any idea.
Thanks!