Send-MailMessage -smtpServer smtp.gmail.com -from 'myself@gmail.com' ` -to 'myself@gmail.com' -subject 'Test' -attachment C:\CDF.pdf 它在消息下方出错,这显然是因为我没有通过我的 gmail 凭据 Send-MailMessage : The SMTP server requires a secure connection or the client was not authenticat...
$msg.Attachments.Add($attachment) $client = new-object System.Net.Mail.SmtpClient $server $client.Credentials = new-object System.Net.NetworkCredential "sender@company.com", "<<PASSWORD>>" $client.EnableSsl = "true" $client.Send($msg) 如果無需驗證用戶的話,那么可以將 Credential 設置為 [Syste...
$mailMessage = New-Object Net.Mail.MailMessage($senderEmail, $recipientEmail, $subject, $htmlBody)$mailMessage.IsBodyHtml = $true$mailMessage.Attachments.Add($attachment) $smtp.Send($mailMessage) # 清理 $smtp.Dispose()$mailMessage.Dispose()$attachment.Dispose()...
那么你可以 Send-MailMessage … -Credential $creds 否则我不明白这个问题 这是我正在做的事情: 发送邮件消息 –到 user1@domain -From sender@domain -Subject “Report” -Body “Summary” -attachment “path of file” -smtpserver mail.mail.com -UseSsl -credential “mycredential;Send-Mailmessage -To...
Send-MailMessage[-Attachments <String[]>] [-Bcc <String[]>] [[-Body] <String>] [-BodyAsHtml] [-Encoding <Encoding>] [-Cc <String[]>] [-DeliveryNotificationOption <DeliveryNotificationOptions>]-From<String> [[-SmtpServer] <String>] [-Priority <MailPriority>] [-ReplyTo <String[]>]...
$Attachment = "C:\Users\HP\Desktop\Tools\Email_on_failure\errorlist.txt" $Subject = "Errors!" $Body = "See attachment" $SMTPServer = "smtp.mail.yahoo.com" $SMTPPort = "465" Send-MailMessage -From gs4u@yahoo.com -to gs4u@outlook.com -Subject $Subject -Body $Body -SmtpServer $...
$SmtpClient = New-Object Net.Mail.SmtpClient($SmtpServer) $SmtpClient.UseDefaultCredentials = $false #$SmtpClient.Credentials = New-Object System.Net.NetworkCredential("wang5@contoso.com", "123456") $SmtpClient.Send($MailMessage) $Attachment.dispose() ...
I want to use a Variable in my Send-MailMessage -Attachment I want to use Cmdlets in Microsoft.Powershell.Archive to archive files. I get error when I try to import that module IAS/NPS Log Parsing identify which network drive was made manually Identifying the first Sunday of a month....
Send-MailMessagecmdlet 还允许你使用命令的许多参数在电子邮件中添加更多详细信息。这是我们可以使用 cmdlet 使用的参数列表。 你可以先将参数值分配给变量,然后再将它们插入命令行以便于阅读。 $From="user@abccompany.net"$To="user@contoso.com"$Copy="manager@contoso.com"$Attachment="C:\Temp\file.jpg"$Su...
$mail.Body ="Hello Powershell" $filename="D:\1.txt"#add file $attachment =new-Object System.Net.Mail.Attachment($filename) $mail.Attachments.Add($attachment) #send the message $smtp = New-Object System.Net.Mail.SmtpClient -argumentList $smtpServer ...