Announcement

Collapse
No announcement yet.

Sending and receiving message

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sending and receiving message

    How to now Sending and Receiving Message in Exchange Server 2003
    Daily,Weekly and Monthly.For all users.

  • #2
    Re: Sending and receiving message

    I think you will need to explain what you need slightly better
    cheers
    Andy

    Please read this before you post:


    Quis custodiet ipsos custodes?

    Comment


    • #3
      Re: Sending and receiving message

      simple SMTP script
      http://www.microsoft.com/technet/scr....mspx?mfr=true
      ________
      Michigan Marijuana Dispensary
      Last edited by DYasny; 6th March 2011, 18:38.
      Real stupidity always beats Artificial Intelligence (c) Terry Pratchett

      BA (BM), RHCE, MCSE, DCSE, Linux+, Network+

      Comment


      • #4
        Re: Sending and receiving message

        'On Error Resume Next

        Dim sEmailAddress, nMonths, sTitle
        sTitle="Exchange Report"
        sEmailAddress = InputBox("For which email address do you want to collect data?",sTitle,"ALL")
        nMonths = InputBox("How many months of data do you want to collect?",sTitle,"0")

        Dim oFSO, oFile
        Dim sLogFileName, sColumnNames, sTempDataLine
        sLogFileName = "ExchangeLog-" & Day(Date) & "-" & Month(Date) & "-" & Year(Date) & "-" & Hour(Time) & Minute(Time) & Second(Time) & ".csv"
        sColumnNames = "Client IP,Client Name,Delivery Time,Encrypted,Entry Type,Key ID,Message ID,Origination Time,Partner Server,Priority,Recipient Count,Sender Address,Server IP,Server Name,Size,Subject,Subject ID,Time Logged,Version"

        Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
        Set oFile = oFSO.CreateTextFile(sLogFileName,True)
        Set oFSO = Nothing

        If Err <> 0 Then
        WScript.Echo "Error occured: " & Err.number & vbCrLf & Err.Description
        WScript.Quit
        End If

        oFile.WriteLine sColumnNames

        Dim dStartDate, sStartDate
        Dim sQuery, sWhere
        sQuery = "SELECT * FROM Exchange_MessageTrackingEntry"
        If Not IsZilch(sEmailAddress) And sEmailAddress <> "ALL" Then
        sWhere = " WHERE SenderAddress = """ & sEmailAddress & """"
        End If

        If CInt(nMonths) > 0 Then
        dStartDate = DateAdd("m",-1*nMonths,Date())
        sStartDate = ConvertDateToWMI(dStartDate)
        If IsZilch(sWhere) Then
        sWhere = " WHERE TimeLogged > """ & sStartDate & """"
        Else
        sWhere = sWhere & " AND TimeLogged > """ & sStartDate & """"
        End If
        End If

        If Not IsZilch(sWhere) Then sQuery = sQuery & sWhere

        'Z sQuery
        'WScript.Quit

        strComputer = "COMPUTER NAME"
        Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")
        Set colItems = objWMIService.ExecQuery(sQuery,"WQL")

        If Err <> 0 Then
        WScript.Echo "Error occured: " & Err.number & vbCrLf & Err.Description
        WScript.Quit
        End If

        For Each objItem in colItems
        sTempDataLine = FormatFields(objItem.ClientIP) & "," & _
        FormatFields(objItem.ClientName) & "," & _
        FormatFields(objItem.DeliveryTime) & "," & _
        FormatFields(objItem.Encrypted) & "," & _
        FormatFields(objItem.EntryType) & "," & _
        Chr(34)& FormatFields(objItem.KeyID) & Chr(34) & "," & _
        FormatFields(objItem.MessageID) & "," & _
        FormatFields(WMIDateStringToDate(objItem.Originati onTime)) & "," & _
        FormatFields(objItem.PartnerServer) & "," & _
        FormatFields(objItem.Priority) & "," & _
        FormatFields(objItem.RecipientCount) & "," & _
        FormatFields(objItem.SenderAddress) & "," & _
        FormatFields(objItem.ServerIP) & "," & _
        FormatFields(objItem.ServerName) & "," & _
        FormatFields(objItem.Size) & "," & _
        FormatFields(objItem.Subject) & "," & _
        FormatFields(objItem.SubjectID) & "," & _
        FormatFields(WMIDateStringToDate(objItem.TimeLogge d)) & "," & _
        FormatFields(objItem.Version)

        Z sTempDataLine

        oFile.WriteLine sTempDataLine
        sTempDataLine = ""
        Next

        oFile.Close
        Set oFile = Nothing

        Set colItems = Nothing
        Set objWMIService = Nothing


        '------------------------------------------------------------
        'Helper Functions
        Function IsZilch(v)
        IsZilch = True

        If VarType(v) = 0 Or VarType(v) = 1 Then Exit Function
        If IsNull(v) Then Exit Function
        If (v & "") = "" Then Exit Function

        IsZilch = False
        End Function 'IsZilch(v)

        Sub Z(s)
        WScript.Echo(s)
        End Sub

        Function IIF(b, c1, c2)
        If b Then
        IIF = c1
        Else
        IIF = c2
        End If
        End Function

        Function FormatFields(s)
        FormatFields = IIf(IsZilch(s),"N/A",s)
        End Function

        Function ConvertDateToWMI(dDate)
        ' Create a date in the string form expected by WMI.
        ' For example, 12 November 2001, 4:29:24 = 20011120042924.000000+000
        ' Time stamps in WMI are compared as strings, and the TimeLogged
        ' property is always given with zero offset from UTC.
        '
        ' Get the UTC-adjusted log-entry cutoff time.
        dtListFrom = dDate
        '
        ' Initialize the time stamp string with the year.
        strStartDateTime = year(dtListFrom)
        ' Add a leading zero for the month, if needed.
        if (Month(dtListFrom) < 10) then strStartDateTime = strStartDateTime & "0"
        ' Add the month value to the string.
        strStartDateTime = strStartDateTime & Month(dtListFrom)
        ' Add a leading zero for the day, if needed.
        if (Day(dtListFrom) < 10) then strStartDateTime = strStartDateTime & "0"
        ' Add the day value to the string.
        strStartDateTime = strStartDateTime & Day(dtListFrom)
        ' Add a leading zero for the hours, if needed.
        if (Hour(dtListFrom) < 10) then strStartDateTime = strStartDateTime & "0"
        ' Add the hours value to the string.
        strStartDateTime = strStartDateTime & Hour(dtListFrom)
        ' Add a leading zero for the minutes, if needed.
        if (Minute(dtListFrom) < 10) then strStartDateTime = strStartDateTime & "0"
        ' Add the minutes value to the string.
        strStartDateTime = strStartDateTime & Minute(dtListFrom)
        ' Add a leading zero for the seconds.
        if (Second(dtListFrom) < 10) then strStartDateTime = strStartDateTime & "0"
        ' Add the seconds value to the string, the part for fractional
        ' seconds, and an empty UTC offset. The empty UTC offset is
        ' needed to match the offset used by the TimeLogged property.
        strStartDateTime = strStartDateTime & Second(dtListFrom) & ".000000+000"

        ConvertDateToWMI = strStartDateTime
        End Function

        Function WMIDateStringToDate(dWMIDate)
        If IsZilch(dWMIDate) Then WMIDateStringToDate = "N/A" : Exit Function
        Dim sTemp : sTemp = Mid(dWMIDate, 5, 2) & "/" & Mid(dWMIDate, 7, 2) & "/" & Left(dWMIDate, 4) & " " & Mid (dWMIDate, 9, 2) & ":" & Mid(dWMIDate, 11, 2) & ":" & Mid(dWMIDate, 13, 2)
        WMIDateStringToDate = CDate(sTemp)
        End Function

        ************************************************** **************
        - Copy the above content and paste it in to notepad and save that file as .vbs the exchange server at c:\scripts
        - Open command prompt and go to c:\scripts
        - Type “cscript filename.vbs” (without quotes)
        - The script will execute and will prompt you asking which email address you want to check. Provide the full email address there. If ALL (default value) is kept, it will pull logs for all email addresses.
        - Next the script will prompt you to provide the time frame for the log file. The value is to be provided in months i.e. 1, 2, 3 and so on. If 0 is kept it will pull logs right from day 1 when the message tracking would have started logging.
        - Finally, you will have an output file in the same directory which is in CSV format. Open that up in Excel and you will have a report which you can sort in Excel to get details.

        NOTE:
        The data size in in KB and the delivery time is in SECONDS.

        Also you can do that through tracking logs from GUI.

        And yes for script and tracking log you need to enable tracking log option.

        SAM
        MCITP - MCTS - MCSE

        Comment

        Working...
        X