Get my Exchange Server mail offline

ilya2004

Board Regular
Joined
Mar 17, 2011
Messages
135
I am trying to get my exchange server mail on my Android, and my company doesn't support Android on the exchange server. I was thinking that it would be good enough to forward my email to a gmail account so I can pick it up there. I tried setting it up via auto-fowarding, but the exchange service blocks the server based auto-forward.

I was thinking I could do some kind of a macro to have my machine foward each piece of mail or try to install an IMAP connection and have my machine copy every piece of mail into the inbox folder of the IMAP.

I tried a few macro's online and couldn't get them to work, and I can't leave my IMAP connection open while I am connected to the VPN.

Does anyone have any ideas either how to get my ideas to work or any other ideas of their own?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
As you found out, Exchange Server would not normally forward to an external email account. I believe that the administrator could override it but it would not be recommended.
You could do it from Outlook VBA but Outlook must be running when the email is received. I have an Outlook rule that will forward an email to another email account on a PC that is always 'ON' and that forwards (using Outlook 2007 VBA) to my home email account. That works whether or not my PC is running.
What version of Outlook are you using?
 
Upvote 0
I'm using 2010. I am fine having the machine running the whole time. How do I set a PC based rule to forward all my mail?
 
Upvote 0
Give the following a try .....
Add the following to the "ThisOutlookSession" class module:
Code:
Option Explicit
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim oItem As Object
Dim oMail As Outlook.MailItem
Dim oNS As Outlook.NameSpace
Dim aItems() As String
Dim lngKount As Long
'
aItems = Split(EntryIDCollection, ",")
Set oNS = Application.GetNamespace("MAPI")
'
For lngKount = LBound(aItems) To UBound(aItems)
    Set oItem = oNS.GetItemFromID(aItems(lngKount))
    If oItem.Class = olMail Then
        Set oMail = oItem
        If oMail.Subject = "Test" Then
            Call ForwardEmail(oMail)
        End If
    End If
Next lngKount
'
Set oNS = Nothing
Set oItem = Nothing
Set oMail = Nothing
'
End Sub
and the following to a code module:
Code:
Option Explicit
Private Const cForwardTo As String = "yourname@yourdomain.com "
Sub ForwardEmail(oReceivedItem As MailItem)
Dim objMail As Outlook.MailItem
Dim oForward As Outlook.MailItem
    '
    On Error GoTo Error_Para
    '
    Set objMail = Application.Session.GetItemFromID(oReceivedItem.EntryID)
    '
    Set oForward = objMail.Forward
    oForward.Subject = objMail.Subject
    oForward.Body = "Forwarded email:-" & vbCrLf & vbCrLf & objMail.Body
    oForward.Recipients.Add (cForwardTo)
' Send:
    'MailItem.Send
' OR Save:
    oForward.Save
    '
    Set oForward = Nothing
    Set objMail = Nothing
    Exit Sub
Error_Para:
    'MsgBox "Error " & Err.num & " (" & Err.Description & ")"
End Sub
You will see that it is currently set to respond to emails with the subject of "Test" and will save the 'forwarded' email in the Drafts folder - so you will need to make changes as required. Also look at adding some error-trapping.
If you have a problem with Outlook security, have a look at Self-signed Certificates:
http://www.howto-outlook.com/howto/selfcert.htm
 
Upvote 0
Fantastic, works perfectly. I only had to change the line:

Code:
MailItem.Save
to
Code:
oForward.Save
, which I assumed was a typo.

Thanks a lot for your help!

-Ilya
 
Upvote 0
That's OK - pleased that it works for you.
Yes, I had not changed the "MailItem.Send" commented line as I only ran it in test mode where the 'save' option was the thing to do.
 
Upvote 0

Forum statistics

Threads
1,221,469
Messages
6,160,027
Members
451,611
Latest member
PattiButche

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top