简体   繁体   English

Outlook 仅根据附件文件名自动保存附件

[英]Saving Outlook Attachments Automatically Based On Attachment File Name Only

I need to save an Outlook file attachment with a static file name to a specific.network location automatically when that email arrives.我需要在 email 到达时自动将文件名为 static 的文件附件保存到特定的网络位置。 This file will be saved in a.network location for upload using a monthly SSI server package. I hope to do this automatically without any interaction but not opposed to manually running a macro.这个文件会保存在一个.network的位置,使用每月的SSI服务器package上传。我希望能自动完成,不需要任何交互,但不反对手动运行宏。 I am unsure of references that are needed in VBA to get this to execute.我不确定 VBA 中需要哪些引用才能执行此操作。 I am also unfamiliar with the "ThisOutlookSession" configuration that I've seen in similar threads我也不熟悉在类似线程中看到的“ThisOutlookSession”配置

I have attempted to use the existing script that I've seen here with no luck.我曾尝试使用我在这里看到的现有脚本,但没有成功。 ( I can get them to run without error but do not get any results ) I want to search all incoming email and only have it take action if the email has an attachment and that attachment has a specific unchanging file name. (我可以让它们无错误地运行但没有得到任何结果)我想搜索所有传入的 email 并且只有在 email 有附件并且该附件具有特定的不变文件名时才采取行动。 I have the developer tab enabled in Outlook and can access VBA through it.我在 Outlook 中启用了开发人员选项卡,可以通过它访问 VBA。 Looking for a solid simple solution.寻找可靠的简单解决方案。 Constants are the file name and extension as well as the.network folder.常量是文件名和扩展名以及 .network 文件夹。 Variables would be the sender and date of delivery.变量将是发件人和交付日期。 Office 365 running Windows 10 in a professional environment. Office 365 在专业环境中运行 Windows 10。 Any help or direction would be greatly appreciated.任何帮助或指导将不胜感激。

You can handle incoming emails in Outlook in the NewMailEx event handler.您可以在NewMailEx事件处理程序中处理 Outlook 中的传入电子邮件。 The event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem , MeetingItem , or SharingItem .对于 Microsoft Outlook 处理的每个收到的项目,该事件都会触发一次。该项目可以是多种不同项目类型之一,例如MailItemMeetingItemSharingItem The EntryIDsCollection string contains the Entry ID that corresponds to that item. EntryIDsCollection字符串包含对应于该项目的条目 ID。 Use the Entry ID string to call the NameSpace.GetItemFromID method and process the item.使用条目 ID 字符串调用NameSpace.GetItemFromID方法并处理项目。 The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. NewMailEx事件在新邮件到达收件箱时和客户端规则处理发生之前触发。

Also, as a possible workaround, you may consider handling the ItemAdd event on the Inbox folder.此外,作为一种可能的解决方法,您可以考虑处理收件箱文件夹上的ItemAdd事件。 This event is fired when one or more items are added to the specified collection.当一个或多个项目添加到指定的集合时,将触发此事件。 This event does not run when a large number of items are added to the folder at once.一次将大量项目添加到文件夹时,不会运行此事件。 For example:例如:

Public WithEvents myOlItems As Outlook.Items 

Public Sub Application_Startup()
 Set myOlItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items 
End Sub 
 
Private Sub myOlItems_ItemAdd(ByVal Item As Object) 
 MsgBox Item.Attachments.Count
End Sub

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

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