擅长:python、mysql、java
<p>接下来呢。。。</em></p>
<hr/>
<pre><code>import win32com.client
Outlook = win32com.client.Dispatch("Outlook.Application")
olNs = Outlook.GetNamespace("MAPI")
Inbox = olNs.GetDefaultFolder("6")
Filter = ("@SQL=" + chr(34) + "urn:schemas:httpmail:subject" +
chr(34) + " Like 'Email Subject' AND " +
chr(34) + "urn:schemas:httpmail:hasattachment" +
chr(34) + "=1")
Items = Inbox.Items.Restrict(Filter)
Items.Sort('[ReceivedTime]', False)
Item = Items.GetLast()
for attachment in Item.Attachments:
print(attachment.FileName)
if attachment.FileName == "Attachment.zip":
attachment.SaveAsFile(r"C:\path\to\my\folder\Attachment.zip")
</code></pre>
<hr/>
<p><em><a href="https://docs.microsoft.com/en-us/office/vba/api/outlook.items.getlast" rel="nofollow noreferrer">Items.GetLast method (Outlook)</a></em></p>
<p><em><a href="https://docs.microsoft.com/en-us/office/vba/api/Outlook.Items.Restrict" rel="nofollow noreferrer">Items.Restrict method (Outlook)</a></em></p>