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

查看:586
本文介绍了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天全站免登陆