Dépôt officiel du code source de l'ERP OpenConcerto
Blame | Last modification | View Log | RSS feed
Add-Type -assembly "Microsoft.Office.Interop.Outlook"
Add-Type -assembly "System.Runtime.Interopservices"
try {
$outlook = [Runtime.Interopservices.Marshal]::GetActiveObject('Outlook.Application')
$outlookWasAlreadyRunning = $true
} catch {
try {
$Outlook = New-Object -comobject Outlook.Application
$outlookWasAlreadyRunning = $false
} catch {
write-host "You must exit Outlook first."
exit
}
}
$mail = $Outlook.CreateItem( [Microsoft.Office.Interop.Outlook.OlItemType]::olMailItem)
$stdin = [Console]::OpenStandardInput()
try {
$sr = New-Object -TypeName 'System.IO.StreamReader' -ArgumentList $stdin,[Text.UTF8Encoding]
$mail.body = $sr.ReadToEnd()
} finally {
$stdin.Close()
}
$mail.subject = @subject@
$mail.to = @to@
foreach ( $att in @attachments@ ) {
$mail.attachments.add($att)
}
$mail.Display()