dre*_*mac 1 microsoft-outlook email script attachments automation
背景:
每个工作日我都会收到一封来自已知发件人的电子邮件。发件人在电子邮件中放入附件。我必须使用 python 脚本处理该附件。
题:
对我来说,将附件从 Outlook 中取出并放到我的 shell 帐户(或本地文件系统)上的最佳(自动)方法是什么,以便我可以使用脚本处理它,而不必每天手动打开文件并保存附件?
小智 6
我正在研究同样的事情,我找到了一个脚本。
复制并粘贴此代码:
(注意:在“Const save_path As String = "c:\Temp\""(用文件服务器的路径替换“c:\Temp\”。记住以“\”结束路径)
Sub SaveToFolder(MyMail As MailItem)
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim objMail As Outlook.MailItem
Dim objAtt As Outlook.Attachment
Dim c As Integer
Dim save_name As String
'Place path to sav to on next line. Note that you must include the
'final backslash
Const save_path As String = "c:\Temp\"
strID = MyMail.EntryID
Set objNS = Application.GetNamespace("MAPI")
Set objMail = objNS.GetItemFromID(strID)
If objMail.Attachments.Count > 0 Then
For c = 1 To objMail.Attachments.Count
Set objAtt = objMail.Attachments(c)
save_name = Left(objAtt.FileName, Len(objAtt.FileName) - 5)
save_name = save_name & Format(objMail.ReceivedTime, "_mm-dd-yyyy_hhmm")
save_name = save_name & Right(objAtt.FileName, 5)
objAtt.SaveAsFile save_path & save_name
Next
End If
Set objAtt = Nothing
Set objMail = Nothing
Set objNS = Nothing
End Sub
Run Code Online (Sandbox Code Playgroud)转到菜单上的调试并编译...