아래의 Outlook 기능을 사용하여 이메일을 보내주십시오. 당신은 실제로저기서 똑같이하고 있습니다. 오류가 있습니까? 어쨌든, 아래 하나를 사용하십시오 : 참조를 위해 함수의 모든 주석을 따르십시오.
Function Global:Send-Email {
[cmdletbinding()]
Param (
[Parameter(Mandatory=$False,Position=0)]
[String]$Address = "[email protected]",
[Parameter(Mandatory=$False,Position=1)]
[String]$Subject = "Mail Subject",
[Parameter(Mandatory=$False,Position=2)]
[String]$Body = "MailBody"
)
Begin {
Clear-Host
# Add-Type -assembly "Microsoft.Office.Interop.Outlook"
}
Process {
# Create an instance Microsoft Outlook
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "$Address"
$Mail.Subject = $Subject
$Mail.Body =$Body
# $Mail.HTMLBody = "HTML BODY"
# $File = "D:\CP\timetable.pdf"
# $Mail.Attachments.Add($File)
$Mail.Send()
} # End of Process section
End {
# Section to prevent error message in Outlook
$Outlook.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Outlook)
$Outlook = $null
} # End of End section!
} # End of function
# Example of using this function
Send-Email #-Address [email protected]
주
: 당신이 누군가를 대신하여 이메일을 보낼 경우 당신은 다른 사람을 대신하여 메일을 보낼 수있는 권한이 있어야 커넥터 또는 사용자로부터 익명의 메일을 활성화해야합니다. 이 경우, 당신은 참조로 Gmail에에서 메일을 보낼 수
$ mail.From = ""
한 샘플 예로서 또 하나의 객체를 추가 할 수 있습니다.
$From = "[email protected]"
$To = "[email protected]"
$Cc = "[email protected]"
$Attachment = "C:\temp\Some random file.txt"
$Subject = "Email Subject"
$Body = "Insert body text here"
$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject `
-Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl `
-Credential (Get-Credential) -Attachments $Attachment
는
... 희망이 도움이