Hey I decided to take another route based on my limited knowledge, which I used for the excel part of it. I think I have most of the code to do what I want. All I really need to know is how to copy from Excel and paste into Outlook, I know I am able to send email using outlook. Could you help me with just the pasting into outlook? Below is the code I am using. I just dont know how to paste it into the body of an outlook email. Thanks.
use Win32::OLE;
use Win32::OLE qw/in with/;
use Win32::OLE::Const 'Microsoft Excel';
use strict;
use warnings;
# Die on errors in Excel
$Win32::OLE::Warn = 3;
# Creates Excel Object
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit');
$Excel -> {"Visible"} = 0;
# Doesnt allow any popups within Excel
$Excel -> {"DisplayAlerts"} = 0;
# Change path to where your files are located
# Opens main Excel file and Center file
my $Book2 = $Excel->Workbooks->Open('C:\TEST\Gold Report.xls');
# copy
$Book2->Worksheets(1)->Range("A2:G2")->Copy;
# This paste it into a different worksheet or workbook
# How would I use this logic to paste it into the
# body of my outlook email?
$Book2->Worksheets(6)->Range("A2:G2")->PasteSpecial;
$mail = new Win32::OLE('Outlook.Application');
$mail->{'Visible'} = 1;
$item = $mail->CreateItem(0);
$item->{'Subject'} = "This is a test";
$item->{'To'} = "image13\@gmail.com";
# I need to be able to paste it here
$item->{'Body'} = "Here is the meat of the message TEST";
$item->Send();
#$mail->Quit();
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.