I'm trying to create a PowerShell script that will open up a new email in outlook and put specific information there.
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "[email protected]"
$Mail.CC = $Outlook.Session.CurrentUser.Name
$Mail.Subject = "sme subject"
$Mail.HTMLBody = "Dear Support,<br><br>" + `
"SOme text here (logfile attached).<br><br>" + `
"URL: ex. https://stackoverflow.com/<br>" + `
"Name of browser: ex. Edge/Chrome<br>" + `
"Proxy name: " + (Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings').proxyServer + "<br>" + `
"LAN/VPN/wifi: <br>" + Get-NetConnectionProfile | select Name, InterfaceAlias + "<br>" + `
## "Kind regards,<br>" + $Outlook.Session.CurrentUser.Name
$Mail.Attachments.Add($logfile)
$Mail.Display()
The email is being created and even the attachment is there, but
"LAN/VPN/wifi: <br>" + Get-NetConnectionProfile | select Name, InterfaceAlias + "<br>" + `
this line/part is not really working and not sure why. It leaves it empty. So after the Proxy name, it will write "LAN/VPN/wifi:" and then the new lines are entered with the signature after.
Could you help me to figure out, what is exactly wrong here, why the value is not in the email body? what should I do to fix this?