Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I've some question about this
https://www.codeproject.com/Tips/863192/Reading-Outlook-Emails-Contents-using-JavaScript

strURL = "http://server/page/sample.aspx"
I don't know about what is the purpose to do this
and I want to know if I use Chrome to browse the page which I wrote, can I use "ActiveXObject" in javscript?

thanks!

What I have tried:

<script>
          function PopulateTable()
            {
                var objOutlook = new ActiveXObject("Outlook.Application");
                var session = objOutlook.Session;
                
                for(var folderCount = 1;folderCount <= session.Folders.Count; folderCount++)
                {
                    var folder = session.Folders.Item(folderCount);
                    if(folder.Name.indexOf("Mailbox - ")>=0)
                    {
                        for(var subFolCount = 1; subFolCount <= folder.Folders.Count; subFolCount++)
                        {
                            var sampleFolder = folder.Folders.Item(subFolCount);
                            if(sampleFolder.Name.indexOf("Sample")>=0)
                            {
                                for(var itmCount = 1; itmCount <= sampleFolder.Items.Count; itmCount++)
                                {                                    
                                    var itm = sampleFolder.Items.Item(itmCount);
                                    if(!itm.UnRead)
                                        continue;
                                    var sentBy = itm.SenderName;
                                    var sentDate = itm.SentOn;
                                    var receivedBy = itm.ReceivedByName;
                                    var receivedDate = itm.ReceivedTime;
                                    var subject = itm.ConversationTopic;
                                    var contents = itm.Body;

                                    var tbl = document.getElementById('tblContents');
                                    if(tbl)
                                    {
                                     var tr = tbl.insertRow(tbl.rows.length);
                                                
                                     if(tbl.rows.length%2 != 0)
                                     tr.className = "alt";

                                     var tdsentBy = tr.insertCell(0);
                                     var tdsentDate = tr.insertCell(1);
                                     var tdreceivedBy = tr.insertCell(2);
                                     var tdreceivedDate = tr.insertCell(3);
                                     var tdsubject = tr.insertCell(4);
                                     var tdcontents = tr.insertCell(5);        
                                     
                                     tdsentBy.innerHTML = sentBy;    
                                     tdsentDate.innerHTML = sentDate;
                                     tdreceivedBy.innerHTML = receivedBy;
                                     tdreceivedDate.innerHTML =    receivedDate;
                                     tdsubject.innerHTML = subject;
                                     tdcontents.innerHTML = contents;
                                     }
                                   itm.UnRead = false;    
                                 }
                                break;    
                            }
                        }
                        break;
                      }
                    }
                return;
            }    

</script>

 <div id="divResult">
       <input type="button" value="Read" onclick="PopulateTable();" /><br />
        <table cellpadding="3" cellspacing="3" border="1" id="tblContents" >
            <tr>
                <th style="width:100px;">Sent By</th>
                <th style="width:80px;">Sent on</th>
                <th style="width:80px;">Recived By</th>
                <th style="width:75px;">Recived on</th>
                <th style="width:75px;">Subject</th>
                <th style="width:200px;">Content</th>
            </tr>
        </table>
    </div>
Posted
Updated 26-May-19 21:47pm

1 solution

Please post your question in the forum at the end of the article, so the writer of the article can help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900