从Outlook 2003中提取特定信息使用VBA Excel中 [英] Extracting specific information from Outlook 2003 to Excel using VBA

查看:221
本文介绍了从Outlook 2003中提取特定信息使用VBA Excel中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,首先,我很新的VBA并且由于我得到按照一定的模板电子邮件的数量,我想自动化数据整理我自己保存所有当前所需的剪切和粘贴。我看了一些previous问题,但由于我知之甚少,答案是不够具体,我听不懂。

So firstly, I'm very new to VBA and due to the number of emails I get that follow a certain template, I'm trying to automate the data collation to save myself from all the cutting and pasting that is currently required. I've looked at some previous questions but due to my very little knowledge, the answers aren't specific enough for me to understand.

这些电子邮件每个人都是从一个特定的电子邮件地址,并有一个标准的格式如下图所示:

Each one of these emails is from a particular email address and has a standard format as shown below:


DD / MM / YYYY hr.min.sec

" dd/mm/yyyy hr.min.sec

XXX XXXXXXX xxxxxxxxxxxxxxxxx XXXX XXXXX

xxx xxxxxxx xxxxxxxxxxxxxxxxx xxxx xxxxx "

我想导出或复制此信息到Excel 2003工作表,这样的信息的每个单独的一块是在一行中,每个电子邮件是一个新行的新列。
我想宏能在一个特定的文件夹在我收到的邮件进行搜索(我已经设置了在与此电子邮件地址前景的一些规则),每个电子邮件复制的信息匹配模板,并将其粘贴到一个Excel工作表。然后每个I得到一个新的电子邮件时,信息将被添加到已创建的表这就是底部。

I would like to export or copy this information to an excel 2003 worksheet so that each separate piece of information is in a new column of a single row, where each email is a new row. I would like the macro to be able to search through my received emails in a particular folder (as I've already set up some rules in outlook relating to this email address), copy the information from each email matching the template and paste it into a single excel worksheet. Then each time I get a new email, the information will be added to the bottom of the table thats been created.

希望这一切是有道理的,请让我知道,如果你需要的信息了。

Hopefully that all makes sense, please let me know if you need anymore information.

先谢谢了。

推荐答案

开始用下面的code:

Start with the following code:

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
  Set Items = GetItems(GetNS(GetOutlookApp), olFolderInbox)
End Sub

Private Sub Items_ItemAdd(ByVal item As Object)
  On Error GoTo ErrorHandler

  Dim msg As Outlook.MailItem

  If TypeName(item) = "MailItem" Then
    Set msg = item



  End If
ProgramExit:
  Exit Sub
ErrorHandler:
  MsgBox Err.Number & " - " & Err.Description
  Resume ProgramExit
End Sub
Function GetItems(olNS As Outlook.NameSpace, folder As OlDefaultFolders) As Outlook.Items
  Set GetItems = olNS.GetDefaultFolder(folder).Items
End Function
Function GetNS(ByRef app As Outlook.Application) As Outlook.NameSpace
  Set GetNS = app.GetNamespace("MAPI")
End Function
Function GetOutlookApp() As Outlook.Application
  Set GetOutlookApp = Outlook.Application
End Function

这对设置默认收件箱事件侦听器。每当收到一封电子邮件,在如果类型名语句中的code将被执行。现在,简直就是c您要运行的$ C $的问题。

This sets an event listener on your default Inbox. Whenever an email message is received, the code inside the If TypeName statement will be executed. Now it's simply a matter of what code you want to run.

您可以使用 .SenderName .SenderEmailAddress 属性,以确保它是正确的发件人检查发件人。

You can check the sender using the .SenderName or .SenderEmailAddress properties to make sure it's the right sender.

如果您提供更具体的信息,我可以修改code。

If you provide more specific information, I can amend the code.

这篇关于从Outlook 2003中提取特定信息使用VBA Excel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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