Outlook 重命名附件并保存到文件夹 [英] Outlook rename attachments and save to folder

查看:35
本文介绍了Outlook 重命名附件并保存到文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,我发现它当前可以保存附件,但我还需要它来将这些附件重命名为相同的名称.

I have a script that I found that currently saves attachments but I also need it to rename those attachments to the same name.

作为一点背景知识,我正在创建一个系统来更新我的一个网站上的库存.为此,我从我们的 ERP 中获得了一份报告(CSV),其中包含我所有的项目编号和库存数量.

For a little background I am creating a system that updates inventory on one of my websites. To do this I get a report(CSV) from our ERP with all my item numbers and inventory counts.

他们已通过电子邮件发送给我,但所附 CSV 的名称始终以不同的数字结尾.

They are emailed to me but the attached CSV always has a name that ends in a different number.

我每次都需要该文件具有相同的名称,因为我拥有的脚本将该 CSV 保存到一个文件夹中,并且我有一个 FTP 程序可以自动将该 CSV FTP 传输到我的 Web 服务器.

I need the file to have the same name every time because the script I have saves that CSV to a folder and I have a FTP program that auto FTPs that CSV to my web server.

从这里开始,我有一个关于 cron 作业的 PHP 脚本,该脚本通过 CSV 运行并更新我的产品数量.

From here I have a PHP script on a cron job that runs through the CSV and updates the quantity on my products.

相信我,如果我的 ERP 有一个 API,这会容易得多,但没有运气.

Believe me, if my ERP had an API this would be so much easier but no luck on that.

无论如何,我的问题在于附件的命名.下面的脚本保存它,但我需要它也从名称中去除数字或将其命名为CPNINVTRUM".

Anyhow, my issue lies in the naming of the attachment. The script below saves it but I need it to also strip the numbers from the name or just name it to 'CPNINVTRUM'.

Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
     Dim objAtt As Outlook.Attachment
     Dim saveFolder As String
     saveFolder = "C:PATH"
     For Each objAtt In itm.Attachments
     objAtt.SaveAsFile saveFolder & "" & objAtt.DisplayName
     Set objAtt = Nothing
     Next
End Sub

附件始终采用以下格式:CPNINVTRUM###.csv.### 表示 ERP 生成的 3 位随机数.

The attachment is always in this form: CPNINVTRUM###.csv. The ### signifies the the 3 digit random number that is generated by the ERP.

推荐答案

将保存行更改为

objAtt.SaveAsFile saveFolder & "CPNINVTRUM.csv"

这篇关于Outlook 重命名附件并保存到文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆