[英]Powershell: Convert email string to valid format for Send-MailMessage cmdlet
So I'm trying to read in a field in a CSV file that contains multiple email addresses, and then use the Send-MailMessage cmdlet to send to those addresses. 因此,我试图读取包含多个电子邮件地址的CSV文件中的字段,然后使用Send-MailMessage cmdlet发送到那些地址。 The string of addresses looks like this in the CSV file.
地址字符串在CSV文件中看起来像这样。
john.doe@domain.com;jane.doe@domain.com
The valid format to send is: 发送的有效格式为:
("john.doe@domain.com", "jane.doe@domain.com")
Does anyone have a good way of transforming the original string to a valid format? 有谁能将原始字符串转换为有效格式的好方法?
Thanks again everybody! 再次感谢大家!
You can use the PowerShell -Split
operator like such: 您可以像这样使用PowerShell
-Split
运算符:
$emailstring = 'john.doe@domain.com;jane.doe@domain.com';
$emailarray = $emailstring -split ';';
Send-MailMessage -To $emailarray ... ...;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.