in reply to Re^4: Outlook email with table
in thread Outlook email with table

"I tried running a test with MIME:Lite. It required me to install all these other packages."

Dependences are common, nothing to worry about.

"Once they were installed I ran into authentication issues. I also installed Authen-SASL but it errored out(no SASL mechanism found at SASL.pm line 77 and SMTP.pm line 143."

At this point I'd suggest that you concentrate on the email aspect of your problem first. Can you detail how you installed MIME::Lite and Authen::SASL? Did either produce warnings or errors? Did you skip installing optional modules while installing these? Post the code which causes this error and provide more data like what sort of mail server are you connecting to, a Microsoft Exchange Server? See also SASL.

Replies are listed 'Best First'.
Re^6: Outlook email with table
by NewMonk2Perl (Sexton) on Jan 24, 2011 at 16:36 UTC
    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();

      I've hardly used Win32::OLE, I'd suggest following the advice in the documentation which suggests referring to the Object Model documentation for the Microsoft Office application in question. It's important to understand what Win32::OLE is, and how to use it. If I were given this task, like your previous question, I'd avoid using Win32::OLE to automate other applications. As previously suggested, I'd use a combination of MIME::Lite and Spreadsheet::ParseExcel.