in order to answer ArsedianIvan question, i figured out that with a sub name like "ListOutlookEmailInfoInExcel", he would be interested to save in an excel file some email information from a shared mailbox.
Here is my suggestion to do that :
Replace "Shared Folder 1" with your shared email name and
I made this script stop after 80 email but you could modify or remove as you like
Sub ListEmailInfoInExcel()
Dim olNS As Outlook.Namespace
Dim olTaskfolder As Outlook.MAPIFolder
Dim olTask As Outlook.TaskItem
Dim olItems As Outlook.Items
Dim olMailItem As Outlook.MailItem
Dim objOwner As Outlook.Recipient
Dim i As Integer
Dim x As Integer
Dim Path As String
Dim RepTemp, NewRep As String
Set olNS = GetNamespace("MAPI")
Set objOwner = olNS.CreateRecipient("Shared Folder 1")
objOwner.Resolve
If objOwner.Resolved Then
Set olTaskfolder = olNS.GetSharedDefaultFolder(objOwner, _
olFolderInbox).Folders("Admin")
Set olItems = olTaskfolder.Items
End If
'Print to a new excel file
Dim objExcel As Object
Dim sheet As Object
Set objExcel = CreateObject("Excel.Application")
Workbooks.Add
'Create a Temp rep in the C drive if it doesn't exist
RepTemp = "C:\Temp\"
NewRep = Dir(RepTemp, vbDirectory)
If NewRep = "" Then
MkDir RepTemp
End If
For Each olMailItem In olTaskfolder.Items
i = i + 1
Range("G" & i).Value = i
Range("H" & i).Value = olMailItem.Sender
Range("I" & i).Value = olMailItem.Subject
Range("J" & i).Value = olMailItem.ReceivedTime
' it will print only 80 email details...
If i = 80 Then
GoTo isenough
End If
Next
isenough:
Path = "C:\Temp\MyNewWorkbook"
ActiveWorkbook.SaveAs Filename:=Path
ActiveWorkbook.Close
End Sub
Yours,