title: How to create mail using Mail::Outlook with Outlook 2007
body: <p>I am trying to create a mail using <code>Mail::Outlook</code>. I followed this answers I believe is correct: </p>
  
  <p><a href="https://stackoverflow.com/questions/10939306/sending-email-using-perl">Sending email using Perl</a><br/>
  <a href="http://search.cpan.org/~duncan/Mail-Outlook-0.23/lib/Mail/Outlook.pm" rel="nofollow noreferrer">Mail::Outlook CPAN</a></p>
  
  <p>I created a simple code based from the tutorials:</p>
  
  <pre><code>use strict;
  use warnings;
  
  use Mail::Outlook;
  use Data::Dumper;
  
  my $outlook = new Mail::Outlook();
  print Dumper($outlook);
  print Dumper(Win32::OLE-&gt;LastError()); #added in response to comment
  
  my $message = $outlook-&gt;create();
  
  $message-&gt;To('sample@gmail.com');
  $message-&gt;Cc('another@gmail.com');
  
  $message-&gt;Subject('Testing sending mail from perl');
  $message-&gt;Body('Hi, This is the body! wahahah!');
  
  $message-&gt;save();
  
  1;
  </code></pre>
  
  <p>The emails I used are real but I replaced it here for privacy's sake..
  When I run the script, an error appeared:</p>
  
  <pre><code>$VAR1 = undef;
  Can't call method "create" on an undefined value at send_mail.pl line 14.  
  </code></pre>
  
  <p>It seems that the variable <code>$outlook</code> did not initialized during <code>new Mail::Outlook()</code>. The module Mail::Outlook returns <code>undef</code> if initiating a new object failed.. Now, I wonder why this happened.. I am thinking it was because of security issues of outlook but I don't know how to tweak that. Please perl masters out there, if anyone has the same experience or have encountered this, it would be helpful..</p>
  
  <p>I am using Microsoft Outlook 2007 in windows 7 and I installed <code>ppm install Mail-Outlook</code>.
  My main question is: <strong>How can I create a mail using Mail::Outlook in Outlook 2007</strong></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I tried using <code>print Dumper(Win32::OLE-&gt;LastError());</code> and it printed this error:</p>
  
  <pre><code>$VAR1 = 'Win32::OLE(0.1709) error 0x80080005: "Server execution failed"';
  </code></pre>