你可以将图像粘贴到outlook Email主体吗?

时间:2015-06-11 03:42:58

标签: perl

我有一个脚本,它截取了Tk Gui的屏幕截图并将其存储在Windows剪贴板中。 我希望然后将图像粘贴到outlook电子邮件正文中,这可能吗? 这就是我到目前为止所做的:

#!/usr/bin/perl
use strict;
use warnings;
use Win32::OLE::Const 'Microsoft Outlook';
use Mail::Outlook;
use Win32::Clipboard;
use Win32::GuiTest qw(FindWindowLike SetForegroundWindow SendKeys);

my @windows = FindWindowLike(0, qr/^test gui/);
for (@windows) {
    SetForegroundWindow($_);
    SendKeys('%{PRTSCR}');
}
my $screen = Win32::Clipboard::GetBitmap() or warn "No image captured: $!\n";
# Print the image to a file.
open    BITMAP, "> C:\\temp\\screen1.jpeg"
  or warn "Couldn't open bitmap file: $!\n";
binmode BITMAP;
print   BITMAP $screen;
close   BITMAP;

# create Outlook message
my $Outlook;
eval {$Outlook = Win32::OLE->GetActiveObject('Outlook.Application')};
die "Outlook not installed" if $@;
unless (defined $Outlook) {
    $Outlook = Win32::OLE->new('Outlook.Application', sub {$_[0]->Quit;})
        or die "Oops, cannot start Outlook";
}
my $outlook = new Mail::Outlook();

my $message = $outlook->create();
$message->To('joebloggs.com');
$message->Subject('test image');
$message->Body( '^V' );

$message->display;

0 个答案:

没有答案