调整 VB 脚本以编程方式创建由电子邮件触发的文件夹
这是我第一次向大家提问。我是一名 SQL 开发人员,对于 VB 非常陌生。
我为我的部门管理一个在线数据库 Quickbase,并通过该网站管理报告申请。我为每个人创建一张票证,该票证会创建一封电子邮件通知开发人员。负责该任务。我们为每个传入的请求设置了文件夹,手动创建所述文件夹非常费力且令人沮丧。
所以我询问并环顾四周,发现了一个能够满足我需要的脚本,至少有人告诉我。但是,我不确定如何根据我的需要定制它,也不知道如何正确实现它。这就是我需要你的帮助的地方,SO的公平编程之神,请帮助我杀死这条龙,王国的所有财富都将是你的*!
Outlook VBA
Sub MakeFile(MyMail As MailItem)
myMailEntryID = MyMail.EntryID
Set outlookNameSpace = Application.GetNamespace(“MAPI”)
Set outlookMail = outlookNameSpace.GetItemFromID(myMailEntryID)
MyArgument = OutlookMail.Subject
Dim sMyCommand = “c:\makefile.bet ” & MyArgument
Shell “cmd /c ” & sMyCommand, vbHide
End Sub
Makefile.bat
@echo off
cls
mkdir %1
网站网址是:www.quickbase.com 根文件夹路径:h:///ntsp/data/reports - criteria/quickbase docs/[要创建的文件夹]
*财富不是金钱,而是只有通过帮助其他书呆子才能获得的善良和完整的感觉,哦,它让 e-peen 变得更加强大!
This is my first time asking a question to y'all. I'm a SQL Developer by trade, and am very green when it comes to VB.
I manage a on-line database for my department, Quickbase, and with this website we manage report requisitions. I create a ticket for each one, and that ticket creates an e-mail notifying the dev. responsible for that assignment. We have folders set up for each request that comes in, and it is very laborious and frustrating to manually create said folders.
So I asked and looked around, coming across a script that was able to do what I needed, or so I am told. However, I'm not sure how to customize it to my needs, nor implement it correctly. This is where I need your assistance, fair programming gods of SO, please help me slay this dragon, and all the riches of the realm will be yours*!
Outlook VBA
Sub MakeFile(MyMail As MailItem)
myMailEntryID = MyMail.EntryID
Set outlookNameSpace = Application.GetNamespace(“MAPI”)
Set outlookMail = outlookNameSpace.GetItemFromID(myMailEntryID)
MyArgument = OutlookMail.Subject
Dim sMyCommand = “c:\makefile.bet ” & MyArgument
Shell “cmd /c ” & sMyCommand, vbHide
End Sub
Makefile.bat
@echo off
cls
mkdir %1
The webtsite URL is: www.quickbase.com
The root folder path: h:///ntsp/data/reports - criteria/quickbase docs/[Folder to be created]
*Riches are not monetary, but the feeling of goodness, and completeness only gained by helping a fellow nerd out, oh and it makes the e-peen grow might and strong!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为一名书呆子,我将帮助您朝着正确的方向开始。我认为仅用VBA就可以实现你想要的,而不需要使用shell。
首先,我们需要挂钩一个事件,说明这一切何时发生。我想那是你的收件箱收到一封电子邮件的时候。如果我就在这里,那就是这一切的开始。
请理解两件重要的事情。
这仅适用于进入收件箱的邮件。因此,如果您已有将项目移动到另一个文件夹的规则,则该规则将不起作用。
您需要“测试”传入的电子邮件 - 我的示例显示了对该主题的测试。仅当且仅当主题中包含“我的测试”时,它才会调用您的特殊例程
在 Visual Basic 编辑器中输入代码:
在“工具”菜单上,指向“宏”,然后单击“Visual Basic 编辑器”。
在“项目”窗格中,单击以展开文件夹,然后双击“ThisOutlookSession”图标。
将以下代码键入或粘贴到“代码”窗口中。
(您可能需要启动和停止 Outlook 才能将变量“挂钩”。
一旦您开始工作并理解了这一点,您就可以删除开关。
然后您必须决定创建一个新文件夹的测试,以便我们然后可以测试电子邮件并将其与现有文件夹进行比较,然后创建一个新文件夹等。
being a fellow nerd I am going to get you started in the right direction. I think we can achieve what you want with VBA alone and do not need to use shell.
First we need to hook an event of when this all should happen. I imagine that is when your inbox gets an email. If I am right here is the start of this.
Please understand 2 important things.
This only works on items coming into your inbox. Thus if you already have a rule moving items to another folder it will not work.
You need to "Test" the email coming in - my example shows a test of the subject. It will only call you special routine IF and ONLY IF the subject has in it "My Test"
To enter the code in the Visual Basic Editor:
On the Tools menu, point to Macro, and then click Visual Basic Editor.
In the Project pane, click to expand the folders, and then double-click the ThisOutlookSession icon.
Type or paste the following code into the Code window.
(You might need to start and stop Outlook to get the variables to "Hook".
Once you get this working and understood, then you can remove the on off switches.
Then you have to decide your test for making a new folder so that we can then test the email and compare it to existing folders and then make a new one etc.