exchange web services

Author Message
faulkkev

  • Total Posts : 593
  • Scores: 13
  • Reward points : 0
  • Joined: 11/1/2005
  • Location: Kansas City, MO
  • Status: offline
exchange web services Monday, November 21, 2011 4:24 AM (permalink)
0
I installed the web service tools but when I run it remotely I just get a prompt not error.  Anyone have any idea what i'm doing wrong.  I have unread emails. 
 
 

$MailboxName = "jj@acme.com"
#Load the dll
$WebServicesdll = "C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll"
[void][Reflection.Assembly]::LoadFile($WebServicesdll)
$Service = New-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP3)
#Connect to Exchange as the current user
$WindowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$SidBind = "LDAP://<SID=" + $WindowsIdentity.User.Value.ToString() + ">"
$AceUser = [ADSI]$SidBind
$Service.AutodiscoverUrl($AceUser.Mail.ToString())
#Hook up to the mailbox folder
$FolderId = New-object  Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
$InboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($Service,$FolderId)
$SearchForUnRead = New-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.EmailMessageSchema]::IsRead, $false)
#Define my item and folder views
$ItemView = New-object Microsoft.Exchange.WebServices.Data.ItemView(2000)
$FolderView = New-object Microsoft.Exchange.WebServices.Data.FolderView(10000)
$FolderView.Traversal = [Microsoft.Exchange.WebServices.Data.FolderTraversal]::Deep
#Find all folders
$AllFolders = $InboxFolder.FindFolders($FolderView);
#Reset total count
$UnReadEmailTotal = 0
#Loop through all the folders found
ForEach ($Folder in $AllFolders){
    "Currently working on : " + $Folder.DisplayName
    If ($Folder.UnreadCount -gt 0){
        "- Number of Unread Messages : " + $Folder.UnreadCount
        $FindItemsResult = $Folder.FindItems($SearchForUnRead,$ItemView)
        "-- Last Mail From : " + $FindItemsResult.Items[0].From.Name
        "-- Subject : " + $FindItemsResult.Items[0].Subject
        "-- Sent : " + $FindItemsResult.Items[0].DateTimeSent
    }
    $UnReadEmailTotal = $UnReadEmailTotal + $Folder.UnreadCount
}
#Output total unread items
"Total unread email : " + $UnReadEmailTotal
 
 
 
 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9