Hi ,
I try to create a sent mail function which will be use by some looping code , it was written in PowerShell code as below , which when i fire the logic in PowerShell ISE , the body message and Email subject where i receive do not have value
function SendOutlookMail([string]$EmailTo , [string]$EmailSubject , [string]$BodyMessageLine1) { $Outlook = New-Object -ComObject Outlook.Application $Mail = $Outlook.CreateItem(0) $Mail.To = $EmailTo $Mail.Subject = $EmailSubject $Mail.Body = $BodyMessageLine1 $Mail.Send() $Outlook.Quit() } # call the function and pass in value to sent mail SendOutlookMail("Some1@email.com" , "Email Subject" , "Body Message")
if i hard code the value by updating this 2 line , everything work fine , where my receive mail body and subject got value
$Mail.Subject = "Email Subject" $Mail.Body = "Body Message"
what is going on ?