简体   繁体   English

使用 Powershell 的邮件自动化任务

[英]Mail Automation Task using Powershell

I had been trying to automate the process of sending mails along with attachments via my outlook account using Powershell.我一直在尝试使用 Powershell 通过我的 outlook 帐户自动发送邮件和附件。

$OL = New-Object -ComObject outlook.application

Start-Sleep 5

<#
olAppointmentItem
olContactItem
olDistributionListItem
olJournalItem
olMailItem
olNoteItem
olPostItem
olTaskItem
#>

#Create Item
$mItem = $OL.CreateItem("olMailItem")

$mItem.To = "PlayingWithPowershell@gmail.com"
$mItem.Subject = "PowerMail"
$mItem.Body = "SENT FROM POWERSHELL"

$mItem.Send()

Stuck with adding attachments in the code.坚持在代码中添加附件。 Please help me out.请帮帮我。

Look at the documentation here .查看此处的文档。

In your case something like:在你的情况下是这样的:

$mItem.Attachments.Add( "C:\My Documents\Q496.xls", olByValue, 1, "4th Quarter 1996 Results Chart"

Arguments are Source, Type, Position & DisplayName. Arguments 是来源、类型、Position 和显示名称。

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

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