• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

how to get unread emails from outlook to an intranet (php)

Our company is using intranet (based on php) for internal needs. They are requesting to have there a notification each time a new message (email) is coming. We use Outlook for email and server is Exchange
0
nfundo
Asked:
nfundo
  • 5
  • 4
1 Solution
 
leakim971PluritechnicianCommented:
Hello nfundo,

Which Exchange version ?

Regards.
0
 
nfundoAuthor Commented:
exchange 2003
0
 
nfundoAuthor Commented:
by mistake
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
leakim971PluritechnicianCommented:
>They are requesting to have there a notification each time a new message (email) is coming

Which type of notification ? An email ?
0
 
nfundoAuthor Commented:
Hello,

a pop up message or on updating of a page counter
0
 
leakim971PluritechnicianCommented:
Happy new year!

You need two PHP page.
A page to check email which will be called by Ajax in the second page

The first :

Line 2, you need to replace IMAP server, username and password of course

<?php
    $imap = imap_open("{mail.server.local:143}INBOX", "username@domain.local", "password");
    $message_count = imap_num_msg($imap);
    print $message_count;
    imap_close($imap);
?>

Open in new window

0
 
leakim971PluritechnicianCommented:
Save the previous page as checkmailimap.php

The page to open which will check if you have new mail every 30 seconds :

You can check immediatly if you have mail at page load and when you click on the button
<html><head>
<title>Check mail account with IMAP</title>
<script language="Javascript">

function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send();
}

function updatepage(str){
    if(parseInt(str)>0) alert("You have " + str + " mail(s)");
}

function timy() {
    xmlhttpPost("http://webserver/checkmailimap.php");
    t=setTimeout("timy()",30000);
}

</script>
</head>
<body onload="timy();">
  <input value="Check NOW if I have mail!" type="button" onclick='JavaScript:xmlhttpPost("http://webserver/checkmailimap.php")'></p>
</body>
</html>

Open in new window

0
 
nfundoAuthor Commented:
none
0
 
leakim971PluritechnicianCommented:
Thanks for the points!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now