Outlook电子邮件附件作为电子邮件

时间:2019-03-22 10:33:05

标签: powershell outlook

我正在使用PowerShell自动执行Outlook收件箱的某些管理。这种想法是,所有进入该收件箱的电子邮件都包含一封电子邮件,我想做一些事情,例如阅读主题,查找正文中的某些字符串等。

我可以从收件箱本身收到的电子邮件中访问此属性,但是当我访问附件时,返回的是com对象,没有任何可用的属性或方法来获取我想要的信息。

$mail.Subject
test email

$mail.Body
This is a test email

$mail.Attachments

Application      : Microsoft.Office.Interop.Outlook.ApplicationClass
Class            : 5
Session          : System.__ComObject
Parent           : System.__ComObject
DisplayName      : test
FileName         : test.msg
Index            : 1
MAPIOBJECT       : System.__ComObject
PathName         : 
Position         : 0
Type             : 5
PropertyAccessor : System.__ComObject
Size             : 30784
BlockLevel       : 0


$att = $mails.Attachments

$att | gm

   TypeName: System.__ComObject#{00063007-0000-0000-c000-000000000046}

Name                 MemberType Definition                                 
----                 ---------- ----------                                 
Delete               Method     void Delete ()                             
GetTemporaryFilePath Method     string GetTemporaryFilePath ()             
SaveAsFile           Method     void SaveAsFile (string)                   
Application          Property   _Application Application () {get}          
BlockLevel           Property   OlAttachmentBlockLevel BlockLevel () {get} 
Class                Property   OlObjectClass Class () {get}               
DisplayName          Property   string DisplayName () {get} {set}          
FileName             Property   string FileName () {get}                   
Index                Property   int Index () {get}                         
MAPIOBJECT           Property   IUnknown MAPIOBJECT () {get}               
Parent               Property   IDispatch Parent () {get}                  
PathName             Property   string PathName () {get}                   
Position             Property   int Position () {get} {set}                
PropertyAccessor     Property   PropertyAccessor PropertyAccessor () {get} 
Session              Property   _NameSpace Session () {get}                
Size                 Property   int Size () {get}                          
Type                 Property   OlAttachmentType Type () {get}  

如何像使用msg对象一样访问此附件?

0 个答案:

没有答案