?
Solved

How to get send receive mails on my exchange 2007 server.

Posted on 2014-04-13
9
Medium Priority
?
188 Views
Last Modified: 2014-04-30
Hi,

I have exchange 2007 server running on windows 2003. I have to present information to my management regarding how many mails are send received on my exchange server per day for all users.

request you to tell me a way out.
0
Comment
Question by:kapoor_sumeet
  • 5
  • 4
9 Comments
 
LVL 23

Expert Comment

by:Patrick Bogers
ID: 39997218
Hi

In ESM you have a mailflow checker, do not specify a sender nor a reciever. Just check per day week month or whatever you want.
0
 

Author Comment

by:kapoor_sumeet
ID: 39997225
Will it give consolidated report on .


Sent mails:
Size of sent mails:
 Size of biggest mail out:
 Average size out:
 Quantity incoming mails:  
 Average size in :
 Overall quantity :
 Overall size :
0
 
LVL 23

Expert Comment

by:Patrick Bogers
ID: 39997231
No it will not, it will only show sended and recieved mails.
To get deeper into what you want you can use a exchange powershell script as provided by MS to help you on your way. The link is here.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kapoor_sumeet
ID: 39997235
I have found following script.

$Localhost = $env:COMPUTERNAME
 #Load Exchange PS Snapin
 If ((Get-PSSnapin | Where-Object {$_.Name -eq “Microsoft.Exchange.Management.PowerShell.E2010¿} ).name -eq ‘Microsoft.Exchange.Management.PowerShell.E2010')
 {
 Write-Host “Exchange Snapin is already loaded….”
}

else
 {
 Write-Host “Loading Exchange Snapin Please Wait….”; Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
 }
 Write-Host “running…”

$hubs = Get-TransportServer

# Get the start date for the tracking log search
 $Start = (Get-Date -Hour 00 -Minute 00 -Second 00).AddDays(-1)

# Get the end date for the tracking log search
 $End = (Get-Date -Hour 23 -Minute 59 -Second 59).AddDays(-1)

$Datum = $Start.ToShortDateString()

$receive = $hubs | get-messagetrackinglog -Start $Start -End $End -EventID “RECEIVE” -ResultSize Unlimited | select Sender,RecipientCount,TotalBytes,Recipients
 $send = $hubs | get-messagetrackinglog -Start $Start -End $End -EventID “SEND” -ResultSize Unlimited | select Sender,RecipientCount,TotalBytes
 $mreceive = $receive | Measure-Object TotalBytes -maximum -minimum -average -sum
 $msend = $send | Measure-Object TotalBytes -maximum -minimum -average -sum

$anzahl = $mreceive.count + $msend.count
 $volumen = ($mreceive.sum + $msend.sum) / (1024 * 1024)

$volumen = “{0:N2}” -f $volumen + ” MB”

$msendmb = $msend.sum / (1024 * 1024)
 $vsend = “{0:N2}” -f $msendmb + ” MB”
$bigsend = $msend.maximum / (1024 * 1024)
 $avsend = $msend.average / 1024

$bigsendmb = “{0:N2}” -f $bigsend + ” MB”
$avsendkb = “{0:N2}” -f $avsend + ” KB”

$mreceivemb = $mreceive.sum / (1024 * 1024)
 $vreceive = “{0:N2}” -f $mreceivemb + ” MB”
$bigreceive = $mreceive.maximum / (1024 * 1024)
 $avreceive = $mreceive.average / 1024

$bigreceivemb = “{0:N2}” -f $bigreceive + ” MB”
$avreceivekb = “{0:N2}” -f $avreceive + ” KB”

#$senders = $send | Group-Object Sender | Sort-Object Count -Descending
 #$topsender = $senders[0].Name
 #$topsender += $senders[0].Count

#$receivers = $receive | Group-Object Recipients | Sort-Object Count -Descending
 #$topreceiver = $receivers[0]
 #$topreceiver

$computer = gc env:computername
 $obj = new-object psObject

$obj |Add-Member -MemberType noteproperty -Name “Generated on server:” -Value $Computer
 $obj |Add-Member -MemberType noteproperty -Name “Date :” -Value $Datum
 $obj |Add-Member -MemberType noteproperty -Name “Sent mails :” -Value $msend.Count
 $obj |Add-Member -MemberType noteproperty -Name “Size of sent mails:” -Value $vsend
 $obj |Add-Member -MemberType noteproperty -Name “Size of biggest mail out:” -value $bigsendmb
 $obj |Add-Member -MemberType noteproperty -Name “Average size out :” -value $avsendkb
 $obj |Add-Member -MemberType noteproperty -Name “Quantity incoming mails :” -Value $mreceive.Count
 $obj |Add-Member -MemberType noteproperty -Name “Size of received mails :” -Value $vreceive
 $obj |Add-Member -MemberType noteproperty -Name “Size of biggest mail in :” -value $bigreceivemb
 $obj |Add-Member -MemberType noteproperty -Name “Average size in :” -value $avreceivekb
 $obj |Add-Member -MemberType noteproperty -Name “Overall quantity :” -Value $anzahl
 $obj |Add-Member -MemberType noteproperty -Name “Overall size :” -Value $volumen

$out = $Datum + “;” + $msend.count + “;” + $vsend + “;” + $mreceive.count + “;” + $vreceive + “;” + $anzahl + “;” + $volumen
 $out | out-file c:\daily.csv -append -encoding default

function sendmail($body)
 {
 $SmtpClient = new-object system.net.mail.smtpClient
 $MailMessage = New-Object system.net.mail.mailmessage
 $SmtpClient.Host = “YOUR_HT_SERVER”
$mailmessage.from = “Exchange_2010_NoReply@YOURDOMAIN.COM”
$mailmessage.To.add(“RECIPIENT@YOURDOMAIN.COM”)
 # $mailmessage.CC.add(“CC_RECIPIENT@YOURDOMAIN.COM”)
 $mailmessage.Subject = “Exchange daily message Report $Datum”
$MailMessage.IsBodyHtml = $false
 $mailmessage.Body = $body

$smtpclient.Send($mailmessage)
 }

$obj = $obj -replace(“@{“,””)
 $obj = $obj -replace(“=”,”:`t”)
 $obj = $obj -replace(“; “,”`n”)
 $obj = $obj -replace(“}”,”`n”)

sendmail $obj


Now how to run this script. Will batch file work or there is some other way to run it.
0
 
LVL 23

Expert Comment

by:Patrick Bogers
ID: 39997238
This is an powershell script which you need to call <filename>.ps1 and if i am not mistaken it needs the powershell snapin build into exchange (#Load Exchange PS Snapin)
0
 

Author Comment

by:kapoor_sumeet
ID: 39997249
Hi

Is powershell snapin there by default or it will load using this script. Other thing is if you can provide some link on how to run script.
0
 
LVL 23

Expert Comment

by:Patrick Bogers
ID: 39997254
By installing Exchange 2007 you also get the exchange toolbox which allows you to run powershell scripts.

Here is a quick guide true on how to use, for example, a mail diagnostics script.
https://www.youtube.com/watch?v=lEn6mjY4zws
0
 

Author Comment

by:kapoor_sumeet
ID: 39997268
hi

if I run following command on exchange powershell

.\xyz.ps1

xyz.ps1 is the script file then it will run script. Is it  the way to run script .

 Please help me I have not used powershell before.
0
 
LVL 23

Accepted Solution

by:
Patrick Bogers earned 1000 total points
ID: 39997272
Yes that is the way to run a powershell script.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
How to effectively resolve the number one email related issue received by helpdesks.
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question