vba 使用收件箱规则将附件从 Outlook 2010 自动下载到本地或网络文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13386029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 18:30:55  来源:igfitidea点击:

Auto download attachment from Outlook 2010 to local or network folder using Inbox Rules

vbaoutlook-2010outlook-vba

提问by Asynchronous

I have this piece of code, it works on one computer Outlook 2010 64bit but does not work on another machine running 32bit. I do not think this has anything to do with 32bit/64 but just want to mention it in-case.

我有这段代码,它适用于一台 Outlook 2010 64 位计算机,但不适用于另一台运行 32 位的计算机。我不认为这与 32bit/64 有任何关系,但只是想提一下以防万一。

I have tried everything, disable macro, turning Outlook inside out and cannot get this code to work.

我已经尝试了所有方法,禁用宏,将 Outlook 翻过来,但无法使此代码正常工作。

Maybe a second eye will find something I am missing:

也许第二只眼睛会发现我遗漏的东西:

Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim dateFormat
dateFormat = Strings.Format(Now(), "mm_dd_yyyy_HH_MM_SS_AMPM")
saveFolder = "C:\Users\Jarvis\Desktop\Test"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & "My_Data_" & dateFormat & ".csv"
Set objAtt = Nothing
Next
End Sub

Thanks everyone!

谢谢大家!

采纳答案by Kevin Pope

Based on our chat, it seems the solution was to:

根据我们的聊天,解决方案似乎是:

  1. Copy EVERYTHING out of your VB macro project, into a text file. Save the textfile to your drive.
  2. Close everything, reboot the computer.
  3. Go to your C:\Documents and settings\\Application Data\Microsoft\Outlook folder.
  4. Either delete the file VBAProject.otm, or (better and safer) rename to VBAProject.old or some similar name.
  5. Open Outlook
  6. Reopen the VB Macro editor
  7. Paste in the code from your text file.
  1. 将 VB 宏项目中的所有内容复制到文本文件中。将文本文件保存到您的驱动器。
  2. 关闭一切,重新启动计算机。
  3. 转到 C:\Documents and settings\\Application Data\Microsoft\Outlook 文件夹。
  4. 删除文件 VBAProject.otm,或者(更好更安全)重命名为 VBAProject.old 或一些类似的名称。
  5. 打开展望
  6. 重新打开 VB 宏编辑器
  7. 粘贴文本文件中的代码。

[Instructions courtesy of Arcane Code]

[说明由奥术代码提供]