#!C:\perl64\bin\perl.exe -w use strict; use Wx; use Mail::Outlook; package MyFrame; use Wx qw (wxVERTICAL wxTOP wxGROW wxHORIZONTAL wxTE_MULTILINE wxFIXED_MINSIZE wxLEFT ); use base 'Wx::Frame'; # import the event registration function use Wx::Event qw(EVT_BUTTON); sub new { my $ref = shift; my $self = $ref->SUPER::new( undef, # parent window -1, # ID -1 means any 'Scan Cards', # title [-1, -1], # default position [430, 140], # size ); my $panel = Wx::Panel->new( $self, # parent window -1, # ID ); my $button = Wx::Button->new( $panel, # parent window -1, # ID 'Save File', # label [40, 40], # position [-1, -1], # default size ); my $sendemail = Wx::Button->new( $panel, # parent window -1, # ID 'Send Email', # label [130, 40], # position [-1, -1], # default size ); $self->{txt} = Wx::TextCtrl->new( $panel, # parent window -1, # control identifier "", # default text value [40, 10], # text control position [x, y] [200, 20], # text control size [width, height] # style: wxTE_MULTILINE=The text control allows multiple lines ); # register the OnClick method as an handler for the # 'button clicked' event. The first argument is a Wx::EvtHandler # that receives the event EVT_BUTTON( $self, $button, \&OnClick ); EVT_BUTTON( $self, $sendemail, \&Email ); return $self; } # this method receives as its first parameter the first argument # passed to the EVT_BUTTON function. The second parameter # always is a Wx::Event subclass sub OnClick { my( $self, $event ) = @_; if (my $rr = $self->{txt}->GetValue()) { print $rr."\n"; my $local = 'C:\Users\christopherc\Documents\Projects\remakes'; my $remote = '\\\\jservdc01\\Fulfill\\Gavehren\\remakes'; my $localFile = $local . "\\" . $rr . "\.txt"; my $remoteFile = $remote . "\\" . $rr . "\.txt"; # save to a dir and put it local and remote open (FH, "> $localFile"); print FH "$rr \n"; close FH; open (REMOTE, "> $remoteFile"); print REMOTE "$rr \n"; close REMOTE; # $self->{txt2}->AppendText($rr."\n"); } $self->SetTitle( 'Clicked' ); } package MyApp; use base 'Wx::App'; sub OnInit { my $frame = MyFrame->new; $frame->Show( 1 ); } sub Email() { my( $self, $event ) = @_; my $msg = "\n"; my $emailSUBJ = "Card number "; my @emailRECIPIENTS; @emailRECIPIENTS = qw(xxx@xxx.com); if (my $rr = $self->{txt}->GetValue()) { $msg .= " $rr\n"; $msg .= " \\\\jservdc01\\Fulfill\\Gavehren\\remakes\n"; } my $outlook = new Mail::Outlook(); my $message = $outlook->create(); $message->To('you@example.com'); $message->Cc('Them '); $message->Bcc('Us ; anybody@example.com'); $message->Subject('Blah Blah Blah'); $message->Body('Yadda Yadda Yadda'); # $message->Attach(@lots_of_files); # $message->Attach(@more_files); # attachments are appended # $message->Attach($one_file); # so multiple calls are allowed $message->send; return; } package main; my $app = MyApp->new; $app->MainLoop;