Maybe I am using the wrong Module for the job? I have a task to get a scanned file and save it to two locations. Then email it to a group.

I have added the Email subroutine to working code and I get this error.

Undefined subroutine &MyFrame::Email called at C:/xxxxx.
here is my program
#!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 allo +ws 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 <them@example.com>'); $message->Bcc('Us <us@example.com>; 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;

In reply to How do i register a new Subroutine in Wx? by crusty_collins

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.