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

You mentioned you wanted it to "look nice(same as if I manually copied it from excel and pasted it into an outlook email)", at this point I wasn't sure if Excel was the source or if the 'table' came from somewhere else, for example an HTML table. It helps to be specific when asking a question.

Regarding reading from Excel see Spreadsheet::ParseExcel, it's similar to Spreadsheet::WriteExcel which I introduced you to previously.

Replies are listed 'Best First'.
Re^4: Outlook email with table
by NewMonk2Perl (Sexton) on Jan 24, 2011 at 15:57 UTC

    Yes, Excel would be the source. Thanks for the help! I was able to get that other issues with the other nodes resolved thanks to you. I tried running a test with MIME:Lite. It required me to install all these other packages. 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. All I am looking for is a way to be able to copy a row from excel and paste it into an email to send.

    Thanks again,

    Paul

      "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.

        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();