pavan6754 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Sending email from excel by one click
by Corion (Patriarch) on May 24, 2011 at 13:11 UTC

    How/where does Perl come into play here? You talk about Excel and then you talk about HTML, and then you talk about an "email pop up". Please explain more clear what should happen where.

Re: Sending email from excel by one click
by marto (Cardinal) on May 24, 2011 at 14:07 UTC

    Are you creating the excel sheet via Perl some how? Sounds like you want to create a Mailto link. See the write_url method of Spreadsheet::WriteExcel.

      yes Marto i am creating excel sheet using Perl script

      but using write_url i can create Mailto Link but what about body(Body should contain filenames owned by owner..)

      So.. Question is i need to create email body which takes cell values as input.

      sorry for the confusion..

      excel sheet is generated through perl script....

      So.. User used to type mail for each owner manually..

      i want to automate this wrk also..can you please help me ...

Re: Sending email from excel by one click
by martell (Hermit) on May 24, 2011 at 21:33 UTC

    To add in excel a body and a subject in the mail link, append the mail address with an attribute part like this in Excel:

    =(Hyperlink("Mailto:me@home.com?Subject=Emailing From Excel&Body=This +is a test"))

    Some fragments that could be handy if you want to send the mail directly with perl.

    If you want to read excel file to obtain the emails given inside.

    use Spreadsheet::Read; #use only for simply excel files # take the filename from commandline and try to take in the excel file my $file1 = ReadData ($excelfile); # obtain the last line on the first sheet my $max_row1 = $file1->[1]{maxrow}; # loop through the rows for (my $i; $i <= $max_row1; $i++) { # read the name on the cell A $i my $name = $file1->[1]{cr2cell ( 1, $i)}; # read the file on the cell B $i my $file = $file1->[1]{cr2cell ( 2, $i)}; }

    To compose an email with perl.

    use MIME::Lite; my $from_address = 'me@home.com'; my $out_server = 'out.home.com'; my $subject = "subject"; my $body = <<"MAIL"; blabla MAIL my $document = 'some data' #open and put data into this my $filename = 'see above' ### Create a new multipart message: my $msg = MIME::Lite->new( From => $from_address, To => $email_address, Subject => $subject, Type => 'multipart/mixed' ); ### Add parts (each "attach" has same arguments as "new"): $msg->attach( Type => 'TEXT', Data => $body ); $msg->attach( Type => $mime_type, Data => $document, Filename => $file, Disposition => 'attachment' ); ### use Net:SMTP to do the sending. Depends on your system what to use +. eval {$msg->send('smtp', $out_server);}; # via a outbound mailserver eval {$msg->send();}; # sending via local send command on linux system

    have a nice day

    Martell

      Thanks a lot Martell.. for detail explanation.. :)

      i want to with first option.. as user will have control over the email which he is sending( i.e he can add other users or extend body..etc )

      Now my Question.. can we have variables in the body (i.e using Hyper LInk),as i want to put cell values in the body

      Thanks

        Normally you can. Simply use the concatenation function '&' in excel. For example:

        =(Hyperlink("Mailto:me@home.com?Subject=" & A3 & "&Body=" & A2 & "Kind + regards"))

        This will put the content of cell A3 in the subject and A2 into the body.

        Search in google on: 'excel mailto body' for other examples.

        Kind Regards

        Martell