Dear monks,

I have the following sub-routine which copies a given range frrom microsft excel and pastes it in the body of microsoft outlook mail. Somehow copy is happening but the paste doesnt happen. could someone please guide me???

sub send_weekly { my $Outlook = Win32::OLE->GetActiveObject ('Outlook.Application') || Win32::OLE->new('Outlook.Application'); my $Outlook = new Win32::OLE('Outlook.Application'); $excel_ob = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); $excel_ob->{Visible} = 0; $excel_ob->{DisplayAlerts}=0; $excel_sheet_name = $day."-".$month."-".($yr19+1900); $dir = getcwd(); $temp = File::Spec->catfile("$dir","Weekly-Report-Vishnu.xlsx"); + $weekly_report_wb = $excel_ob->Workbooks->Open($temp) or die "Coul +d not open Weekly sheet $!"; $weekly_report_ws = $weekly_report_wb->Worksheets($excel_sheet_nam +e) or die "Couldn't open Weekly Report $!\n "; $weekly_report_ws->Range("A1:H26")->Copy; # Create Mail Item my $item = $Outlook->CreateItem(0); # 0 = mail item. unless ($item) { die "Outlook is not running, cannot send mail.\n"; } $item->{'Subject'} = $subject; $item->{'To'} = $to; #$weekly_report_ws->Range("A1:H26")->Copy; $item->{'Body'}= $item->PasteSpecial($weekly_report_ws->Range("A1: +H26")->Copy); $item->{'From'} = $from; $item->{'Cc'} = $cc; # 2=high, 1=normal, 0=low $item->{'Importance'} = $priority ; # Send the Email $item->Send(); }


In reply to OLE module by vishnu.h

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.