Outlook and Attachment

Hello All,

i’m really newbie on powershell, and i’m studying it , i would like to create a script that inside a shared mailbox, can catch mail from a specific sender and save the attachment.

i’m trying lot of roads but no one seems to be the case.

I Used the for loop like an example:

$MailboxName = "na@na.com"
$olFolderInbox = 6
$olFolderPath = "\\na@na.com\Inbox\cc1\Received"
$outlook = new-object -com outlook.application; 
$namespace = $outlook.GetNameSpace("MAPI"); 
$recipient = $namespace.CreateRecipient($MailboxName)
$inbox = $namespace.GetSharedDefaultFolder($recipient,6) 
$messages = $inbox.items

$filepath = "C:\temp\pdfToMerge" 

$oltargetFolder = $inbox.Folders | Where-Object { $_.FolderPath -eq $olFolderPath}

$email = $oltargetFolder.Items

foreach ($email in $emails) {

  $SenderAdd = $email.From.ToString
  write-host "ecco" $SenderAdd


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.