简体   繁体   English

Powershell 脚本,在不知道 email 地址的情况下,将 email(通过 Outlook)发送给脚本用户

[英]Powershell Script, send email (via Outlook) to user of script without knowing email address

My goal is to send an email containing log information to the person who ran the script.我的目标是向运行脚本的人发送包含日志信息的 email。
Right now using现在使用

$Mail.To = "firstname.lastname@gmail.com"

I can manually type in the name of the user who I think should get the information.我可以手动输入我认为应该获取信息的用户的名称。 But I just want to know if there is a way for me to obtain the email address in some automatic way.但我只想知道是否有办法以某种自动方式获取 email 地址。 I know that the application automatically sends the email from the logged in user.我知道应用程序会自动从登录用户发送 email。 Could I use that same feature to my benefit?我可以使用相同的功能来为自己谋利吗?

This email is sent out using:此 email 使用以下方式发送:

$Outlook = New-Object -ComObject Outlook.Application
...
...
$Mail.Send()

In the Outlook object model you can find the Account.SmtpAddress property which returns a string representing the Simple Mail Transfer Protocol (SMTP) address for the Account .在 Outlook object model 中,您可以找到Account.SmtpAddress属性,该属性返回代表Account简单邮件传输协议 (SMTP) 地址的字符串。 The purpose of SmtpAddress and Account.UserName is to provide an account-based context to determine identity. SmtpAddressAccount.UserName的目的是提供基于帐户的上下文来确定身份。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM