So, first things first. get-mailboxstatistics is notoriously slow, i have been using it on customers with 16.000 mailboxes, and that script will take forever to complete. So please use with caution.
If i were to make it like you did, i would do it like below. If i read the error message correctly (the last part of it), it seems to have issues finding the identity of the user. I usually never pipe directly to a foreach, and as such can't tell exactly why it fails, but the below code should fix it.
$All = Import-CSV "C:\temp\userfiles.csv"
$exportpath = "C:\temp\exportfile.csv"
foreach($i in $All)
{
$mailbox = $i.UserPrincipalName
$quota = Get-Mailbox -identity $mailbox | select ProhibitSendQuota, ProhibitSendReceiveQuota, RecoverableItemsQuota, ArchiveQuota, ArchiveWarningQuota
$CurrentMailboxUsedSize = Get-MailboxStatistics -identity $mailbox | select TotalItemSize
$recoverableitem = Get-MailboxFolderStatistics -identity $mailbox | ? {$_.Name -eq "Recoverable Items"}
$p = @{
UserPrincipalName = $mailbox
CurrentMailboxUsedSize = $CurrentMailboxUsedSize.TotalItemSize
ProhibitSendQuota = $quota.ProhibitSendQuota
MailboxTotalSize = $quota.ProhibitSendReceiveQuota
CurrentRecoverableItemsSize = $recoverableitem.FolderAndSubfolderSize
RecoverableItemsQuota = $quota.RecoverableItemsQuota
ArchiveMailboxQuota = $quota.ArchiveQuota
ArchiveWarningQuota = $quota.ArchiveWarningQuota
}
$objcmddata = New-Object -TypeName psobject -Property $p
$objcmddata | select-object | Sort-Object 'UserPrincipalName', 'CurrentMailboxUsedSize', 'CurrentRecoverableItemsSize', 'ProhibitSendQuota', 'MailboxTotalSize', 'RecoverableItemsQuota', 'ArchiveMailboxQuota', 'ArchiveWarningQuota' | Export-CSV $exportpath -NoTypeInformation -Encoding UTF8 -Delimiter ';' -Append
}