VFP:我怎样才能访问Outlook附件的内容 [英] VFP: How can I access the contents of an Outlook attachment

查看:408
本文介绍了VFP:我怎样才能访问Outlook附件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,读取和使用Outlook自动发送电子邮件,从Visual FoxPro。

I have a program that reads and send emails using Outlook automation, from Visual FoxPro.

我具备的功能来检索和保存附件,但我想读的附件为一个字符串的内容,而无需将文件保存到磁盘上。

I have functions to retrieve and save attachments, but I would like to read the contents of an attachment to a string without saving the file to disk.

在下面的例子中,我实例化展望,拿起一个命名空间,并为当前用户的收件箱的参考。然后,我拿起引用到任意消息(收件箱中的32号),并引用到邮件的附件。

In the example below, I instantiate Outlook, pick up a namespace and a reference to the current user's inbox. I then pick up a reference to an arbitrary message (number 32 in the inbox), and a reference to the message's attachment.

oOutlook = createobject('Outlook.Application')
oNamespace = oOutlook.GetNamespace('MAPI')
oInbox = oNamespace.GetDefaultFolder(olFolderInbox)
oMessage = Inbox.Items[32]
oAttachment = oMessage.Attachments[1]

在这一点上,我会打电话:

At this point I would call:

oAttachment.SaveAsFile('C:\Example\File1.xml')

将文件保存到磁盘。

to save the file to disk.

我想要做的就是读取文件到字符串的内容,如果没有它保存到磁盘。

What I want to do is to read the contents of the file to a string, without saving it to disk.

在此特定实例,该文件是XML。

In this particular instance, the file is XML.

推荐答案

不幸的是没有方法来存储Outlook附件内存,而无需使用第三方库,如果是超过8KB更大尺寸。

Unfortunately there is no way to store an Outlook attachment to memory without using third party libraries, if it is greater than 8KB in size.

在Outlook 2007中,你可以调用Attachment.PropertyAccessor.GetProperty到PR_ATTACH_DATA_BIN属性读取到内存中,如果附件小于8KB。

In Outlook 2007, you can call Attachment.PropertyAccessor.GetProperty to read the PR_ATTACH_DATA_BIN property to memory if the attachment is less than 8KB.

如前所述,赎回是如果你使用第三方库的最佳选择。

As mentioned, Redemption is the best bet if you were to use a third-party library.

这篇关于VFP:我怎样才能访问Outlook附件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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