Outlook Sent Recieve times

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
Hello,
I have been having trouble with email being delayed. In order to show our tech what I was talking about I wanted to loop thorugh all the mail in a folder and either writing to a text file or some other export the sent/recieve times. I feel confident in getting the info to a text file once I pull it into the program, however I am fairly inexperienced with Outlook's object structure so I need help looping through the mail and access the sent/recieve times. Anyone know the keywords?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi Oorang,

Maybe something like this ...



<font face=Tahoma New><SPAN style="color:#00007F">Sub</SPAN> LoopThrough_SentReceived()
    <SPAN style="color:#00007F">Dim</SPAN> NS <SPAN style="color:#00007F">As</SPAN> Namespace
    <SPAN style="color:#00007F">Dim</SPAN> Sent <SPAN style="color:#00007F">As</SPAN> MAPIFolder
    <SPAN style="color:#00007F">Dim</SPAN> Email <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> Cnt <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
    <SPAN style="color:#00007F">Set</SPAN> NS = GetNamespace("MAPI")
    <SPAN style="color:#00007F">Set</SPAN> Sent = NS.GetDefaultFolder(olFolderSentMail)
    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> Email <SPAN style="color:#00007F">In</SPAN> Sent.Items
        Cnt = Cnt + 1
    <SPAN style="color:#00007F">Next</SPAN> Email
    MsgBox Cnt
    <SPAN style="color:#00007F">Set</SPAN> Sent = <SPAN style="color:#00007F">Nothing</SPAN>
    <SPAN style="color:#00007F">Set</SPAN> NS = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>



This will loop you through all items in your Sent Items folder. That what you're looking for?
 
Upvote 0
Hey Firefyter :LOL: , I can confirm that works. The solution I ended up using (but never posted) was:
Code:
Option Explicit
Sub A()
Dim OLNameSpace As NameSpace
Dim OLFolder As Outlook.MAPIFolder
Dim intLC As Integer
Dim objFileSystem As Object, objFile As Object
Dim strSenderName As String
Dim dtSentOn As Date, dtReceivedTime As Date
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Set OLNameSpace = Application.GetNamespace("MAPI")
Set OLFolder = OLNameSpace.Folders("Local Mail File")
Debug.Print OLFolder.Items.Count

Set objFileSystem = CreateObject("Scripting.FileSystemObject")
objFileSystem.createtextfile "c:\mailPerformace.csv"
Set objFile = objFileSystem.OpenTextFile("c:\mailPerformace.csv", ForWriting, TristateFalse)
objFile.Write "Sender Name,Subject,Sent On,Recieved Time,Variance" & Chr(10)

For intLC = 1 To OLFolder.Items.Count
Debug.Print intLC
If Mid(OLFolder.Items(intLC), 1, 14) = "Undeliverable:" Then
    strSenderName = ""
    dtSentOn = 0
    dtReceivedTime = 0
    Else
    strSenderName = Replace(OLFolder.Items(intLC).SenderEmailAddress, ",", "")
    dtSentOn = Replace(OLFolder.Items(intLC).SentOn, ",", "")
    dtReceivedTime = Replace(OLFolder.Items(intLC).ReceivedTime, ",", "")
    End If
objFile.Write strSenderName & Chr(44) & OLFolder.Items(intLC).Subject & Chr(44) _
            & dtSentOn & Chr(44) & dtReceivedTime & Chr(10)
Next intLC

objFile.Close
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,331
Messages
6,124,311
Members
449,152
Latest member
PressEscape

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top