damienvanrobaeys / About_my_device

About my device: A systray tool for that displays device information and run action like send logs or sync device
34 stars 6 forks source link

Outlook close after send Mail #8

Open afetscher opened 3 years ago

afetscher commented 3 years ago

AboutMyDevice_Systray.ps1

$Mail.Send() $Outlook.Quit() [System.Runtime.Interopservices.Marshal]::ReleaseComObject($Outlook) | Out-Null

I think it would be better to omit the close, because Outlook is permanently used by users.

maheDJ commented 3 years ago

Or check before if it's running and depending on it close it or not :)

damienvanrobaeys commented 3 years ago

Thanks for the feedback, I will resolve that

damienvanrobaeys commented 3 years ago

I just resolved the issue. I will update the systray file tomorrow

damienvanrobaeys commented 3 years ago

I will now use the comobject as below: $Get_Outlook_Process = get-process outlook -ea silentlycontinue If($Get_Outlook_Process -ne $null) { $outlook = [Runtime.InteropServices.Marshal]::GetActiveObject("Outlook.Application")
} Else {
$Outlook = New-Object -ComObject Outlook.Application }