使用Perl搜索Lotus Notes收件箱

时间:2011-08-05 14:36:28

标签: perl lotus-notes

我正在尝试搜索我的收件箱以查找特定的电子邮件,但每次我尝试运行此脚本时,$ search都是未初始化/未定义的。语法有问题吗?

use Win32::OLE;
use Win32::OLE::TypeInfo;

#Create a new NotesSession, which is basically like a new Lotus Notes instance
my $Notes = Win32::OLE->new('Notes.NotesSession') or die "Could not open Lotus Notes";

#Prints the current user of Lotus Notes
print "The current user is $Notes->{UserName}.\n";

#Gets the stuff in the listed Database
my $Database = $Notes->GetDatabase('Server', 'mail.nsf');

# Open the mail
$Database->OpenMail;

# Create a new Document, ie email
my $Document = $Database->CreateDocument;

# Send the email to someone
$Document->{SendTo} = ;
# CC the email to someone 
$Document->{SendCc} = ;
# Subject of the email
$Document->{Subject} = 'Test';

my $date = $Notes->CreateDateTime("Today");
my $today = $date->DateOnly;

my $search = $Database->Search("@Tripwire",$today,5);
print $search->Count;

由于

3 个答案:

答案 0 :(得分:4)

“@ Tripwire”应该是:用于定义选择标准的Notes @function公式。这意味着它需要与视图选择公式中的字符串类似。像Sendto =“@ TripWire”

答案 1 :(得分:1)

或者您在数据库中启用全文搜索并使用FtSearch而不是搜索。

答案 2 :(得分:0)

我不是Perl程序员,但相信你还有其他问题。通过COM接口设置或访问NotesItem值不支持“扩展语法”表示法。即,您对$ Document-> {SendTo},$ Document-> {SendCc}和$ Document-> {Subject}的引用不正确。您应该使用$ Document-> ReplaceItemValue并提供项目名称和值作为参数。此外,SendCC不是正确的项目名称。它应该是CopyTo。