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

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

问题描述

我需要自动化一项涉及的特定任务:

  • 根据一组条件从我的邮箱中获取邮件 - 来自特定用户、具有特定主题行模式等.

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

  • 使用特定模板创建 Excel 工作表(前两行是不变的,第三行是本周的星期一和星期五等),并将上面提取的内容逐行粘贴到该工作表中.

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

  • 在此邮件中附上上述 Excel 表格.

(终于发送了,但我不想自动化那部分 - 我喜欢在发送邮件之前仔细检查一下.)

现在,当我想到自动化这项任务时,我立刻想到了 Perl 的 Win32::OLE,因为我最近了解了它,并且对 Perl 非常熟悉.但是,我认为 Visual Basic for Automation 可能更适合该任务,因为它是为此类任务创建的语言.

我的问题是,VBA 是否足以抵消我在 Perl 和 VB 之间的技能差异?几年前我还是个孩子的时候就玩过 VB6,但这与我的 VB 经验有关.

我也愿意接受任何其他语言/平台建议,前提是它们具有一定的灵活性并且不太难学.我也知道一些 Python.

我查看了这个,还有这个这个this这个,但它们要么不相关,要么没有任何好的答案.

解决方案

我问了 适用于 Windows 程序员的最佳官方"脚本语言,答案主要是 PowerShell.这是我发现自动化 Outlook 的链接:使用 PowerShell 实现 Outlook 自动化.

$outlook = new-object -com Outlook.Application

<块引用>

查看您发送的前 5 封电子邮件的主题

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

和 Excel:PowerShell 和 Excel.

$a = new-object -comobject excel.application

<块引用>

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

$a.ActiveSheet.Range("B1").Value2 = "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"

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

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