Fetching and (semi) FW’ing OWA Mail to Gmail Using msfetch

In the world of web, sometimes the web just isn't convenient!  This is true when you are *forced* to use the web to check email.  My latest job only allows me to check email using Outlook Web Access or OWA.  Even worse, they removed the ability to forward emails and IMAP/POP access.

There are a couple of solutions out there but I couldn't get any of them to work ... in comes msfetch ( http://www.isrcomputing.com/msfetch/).

When I initially installed the tool for (outlook 2007) on my linux machine, I had issues getting it working.  Huge thanks to Paul (owner) for working with me.

In these examples I will be using the variables:

  • username: myusername
  • email: myuser.name@mydomain.com

Take note that the username and email is different!  This will be the root of our issues below.

First thing I had to do was download and install the scripts (took all of 5 seconds).  Then we need to edit the .msfetchrc file.  Here is an example of a WORKING copy ... not the one that gave me problems.


#Exclude e-mail collection from the folders below

turn on DEBUG within the msfetchrc script.  This was easy to do.  Simply uncomment out the DEBUG line near the top.

Once this was done I executed and got these errors near the bottom:

Login successful!
Listing E-Mail Folders...
Query: SELECT "DAV:id", "DAV:href" FROM
"https://email.mydomain.com/exchange/myusername/" WHERE "DAV:ishidden" = false
AND "DAV:isfolder" = true
Fetch folder listing failed (https://email.mydomain.com/exchange/myusername/)...
440 Login Timeout
Number of folders: 0
There are no folders to fetch.
Started:   2009/12/28 17:06:58
Completed: 2009/12/28 17:06:59

Again, working with the author, he was able to try a couple of tricks and it turns out that my login name "myusername" in this example is different than my email "myemail.name".  The real example is dmauro -vs- douglas.mauro.  This was screwing up the WebDav and some changes needed to be made in the msfetchrc script

Line:61 - I commented out the original and inserted the new line above

Line :61
my $strUrl = $strProt."://" . $strServer . "/exchange/myemail.name/";
#my $strUrl = $strProt."://" . $strServer . "/exchange/" . $strAlias . "/";

You could also modify the line 62 to get Sent items (I didn't in this example).

It works! Here is a run (no emails):

[root@localhost ~]# ./msfetch

msfetch v0.4 - download e-mail messages from Exchange OWA 2000/2003/2007 to mbox

Login successful!
Listing E-Mail Folders...
processing folder (https://email.mydomain.com/exchange/myuser.name/Inbox/)
skipping folder (https://email.mydomain.com/exchange/myuser.name/Outbox/), exclusion list...
skipping folder (https://email.mydomain.com/exchange/myuser.name/Sent%20Items/), exclusion list...
skipping folder (https://email.mydomain.com/exchange/myuser.name/Deleted%20Items/), exclusion list...
skipping folder (https://email.mydomain.com/exchange/myuser.name/Calendar/), exclusion list...
skipping folder (https://email.mydomain.com/exchange/myuser.name/Contacts/), exclusion list...
skipping folder (https://email.mydomain.com/exchange/myuser.name/Drafts/), exclusion list...
skipping folder (https://email.mydomain.com/exchange/myuser.name/Journal/), exclusion list...
skipping folder (https://email.mydomain.com/exchange/myuser.name/Notes/), exclusion list...
skipping folder (https://email.mydomain.com/exchange/myuser.name/Tasks/), exclusion list...
skipping folder (https://email.mydomain.com/exchange/myuser.name/Junk%20E-Mail/), exclusion list...
Number of folders: 1
Fetching https://email.mydomain.com/exchange/myuser.name/Inbox/
Completed https://email.mydomain.com/exchange/myuser.name/Inbox/
Started:   2009/12/29 11:33:47
Completed: 2009/12/29 11:33:48

Of course I couldn't leave well enough alone. I wanted a way to notify me via pop/imap when I get email on this account. I turned to setting up mutt to use gmail and ran a *crude* 1 liner to send emails to my account


print "Message ($web_id) fetch successful...\n";

# New line below
  `su - douglasmauro -c 'mutt -s \"FUN-EMAIL-MSG: $web_header \" douglasmauro\@mygmailaccount.com < /dev/null'`;

 return 0;

Going into my douglasmauro account on the system reveals a .muttrc of:

set realname = "Douglas R. Mauro"
set spoolfile = imaps://imap.gmail.com:993/INBOX
set imap_user = 'username@mygmaildomain.com'
set imap_pass = 'mypassword'
set smtp_url="smtp://username@mygmaildomain.com@smtp.gmail.com:587/"
set smtp_pass = 'mypassword'
set folder = imaps://imap.gmail.com:993
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"
set record=""
set imap_check_subscribed="yes"
set imap_list_subscribed="yes"
set header_cache="~msgcache"
set certificate_file="~.mutt_certificates"
set mbox="imaps://imap.gmail.com/[Gmail]/All Mail"

and a simple entry into cron

[root@localhost ~]# crontab -l
*/5 * * * * /root/msfetch 2>&1 > /dev/null # Fetch OWA Mail
[root@localhost ~]#

Now every 5 minutes, it'll check this OWA account and forward an EMPTY msg to the email I listed with the subject = $web_header.

yes, yes, I could find a way to forward the whole msg but this is soo much easier 😉

More thanks to Paul for helping me get this working!

Leave a Reply

Your email address will not be published.