什么是自动执行此Windows任务涉及Outlook和Excel中的最好的语言? [英] What's the best language to automate this Windows task involving Outlook and Excel?

查看:119
本文介绍了什么是自动执行此Windows任务涉及Outlook和Excel中的最好的语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要自动化,涉及到一个特定的任务:


  • 这是基于一套标准,我的邮箱抓取邮件 - 从一个特定的用户,有主题行等的特定模式


  • 解析每封邮件的邮件正文和提取的一些内容(邮件有一个几乎固定的模式)


  • 创建一个Excel工作表与一个特定的模板(前两行是不变的,第三行是这个星期,等周一和周五),并粘贴上面提取到本表中连续行的内容。


  • 创建具有不同的格式相同内容的Outlook电子邮件


  • 附加Excel工作表与此邮件上方。

(最后送了,但我不希望自动执行的一部分 - 我喜欢加倍发送邮件之前检查的东西)

现在,当我想到这个自动化的任务,Perl的Win32的:: OLE浮现在脑海立刻因为我已经知道了,就最近和我在Perl很舒服。但后来,我还以为Visual Basic的自动化可能是更适合的任务,因为它是这样的任务创建的语言。

我的问题是,是VBA更好足以抵消我的Perl和VB之间技能的区别?我已经打了VB6,当我还是个孩子几年前,但是这是关于我的VB经验的程度。

我接受任何其他语言/平台的建议为好,只要它们允许一定的灵活性,并且不太难学了。我知道一些Python以及。

我看了<一个href=\"http://stackoverflow.com/questions/1818266/what-is-the-easiest-way-to-automate-excel-tasks\">this并且还<一href=\"http://stackoverflow.com/questions/1240096/automate-collection-of-data-from-outlook-msg-files-to-excel-field\">this, <一href=\"http://stackoverflow.com/questions/1177224/automating-outlook-and-word-to-create-email-message\">this, <一href=\"http://stackoverflow.com/questions/461869/automate-excel-file-processing-in-perl-and-avoid-dialog-ui-interactions\">this和<一个href=\"http://stackoverflow.com/questions/1140311/using-python-to-automate-creation-manipulation-of-excel-s$p$padsheets\">this,但他们要么是不相关的,或者没有任何好的答案。


解决方案

我问<一个href=\"http://stackoverflow.com/questions/326775/best-official-scripting-language-for-windows-programmers\">Best 官方的脚本语言的Windows程序员,得到的回答大多是的PowerShell 。这里有一个链接,我发现自动运行Outlook:<一href=\"http://blogs.msdn.com/jmanning/archive/2007/01/25/using-powershell-for-outlook-automation.aspx\"相对=nofollow>使用PowerShell中的Outlook自动化。

  $ =展望新的对象-com Outlook.Application


  

看你发送的第一个5封电子邮件的主题


  $ sentMail = $ outlook.Session.GetDefaultFolder(5)#== olFolderSentMail
$ sentMail.Items |选择-first 5 TASKSUBJECT

和Excel中:的PowerShell和Excel

  $ a =新的对象-ComObject excel.application


  

如何更改指定单元格的值?


  $ a.ActiveSheet.Range(B1)。值2 =Y

I need to automate a particular task that involves:

  • Fetching mails from my mailbox based on a set of criteria - from a particular user, has a particular pattern of subject line, etc.

  • Parsing the mail body of each mail and extracting some content (the mails have an almost fixed pattern)

  • Creating an Excel sheet with a particular template (the first two lines are constant, the third line is the Monday and Friday of this week, etc.) and paste the content extracted above into this sheet in successive lines.

  • Creating an Outlook email message with the same content in a different format

  • Attaching the above Excel sheet with this mail.

(Finally sending it, but I don't want to automate that part - I like to double check things before sending out mails.)

Now, when I thought of automating this task, Perl's Win32::OLE came to mind immediately since I'd learnt about it recently, and am very comfortable in Perl. But then, I thought Visual Basic for Automation might be more suited for the task, since it is a language created for such tasks.

My question is, is VBA better enough to offset the difference in my skillset between Perl and VB? I've played with VB6 when I was a kid years ago, but that's about the extent of my VB experience.

I'm open to any other language/platform suggestions as well, provided they allow some flexibility and aren't too difficult to learn. I know some Python as well.

I looked at this and also this, this, this and this, but they either are not relevant, or do not have any good answers.

解决方案

I asked Best "official" scripting language for Windows programmers, and the answer was mostly PowerShell. Here's a link I found automating Outlook: using PowerShell for Outlook automation.

$outlook = new-object -com Outlook.Application

Look at the subjects of the first 5 emails you sent

$sentMail = $outlook.Session.GetDefaultFolder(5) # == olFolderSentMail 
$sentMail.Items | select -first 5 TaskSubject    

And Excel: PowerShell and Excel.

$a = new-object -comobject excel.application

How do I change the value of a specified cell?

$a.ActiveSheet.Range("B1").Value2 = "y"

这篇关于什么是自动执行此Windows任务涉及Outlook和Excel中的最好的语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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