Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Thursday, June 5, 2008

Sending an email from PHP (on Windows too.)

Yey, finally got something that really works.
It's not my stuff, but I was able to found it after a long time search!
Here is the link to sourceForge.net, to the page that hosts php Mailer for PHP 5 for Windows, and looks like for Unix too. If the link does not work then search for the word phpMailer.

The easiest way to install the stuff is to do as follows (example on Windows, with assumption that you have your php installed in the c:\php directory.)

> mkdir c:\php\mailer
Unzip phpMailer_v2.1.zip into c:\php\mailer
> notepad.exe c:\php\php.ini
Add at the very end:
include_path=".;c:\php\mailer"

Youre done!

Now, example:
>
<?php
require_once( "class.phpmailer.php" ) ;

$mail = new PHPMailer() ;
$mail->IsSMTP() ;
$mail->Host = "smtp.myserver.com:587" ;
$mail->SMTPAuth = true ;
$mail->Username = "username" ;
$mail->Password = "password" ;
$mail->From = "me@myserver.com" ;
$mail->FromName = "It is me!" ;
$mail->AddAddress( "testaddress@theirserver.com", "Poor Receiver" ) ;
$mail->AddReplyTo( "me@myserver.com", "do-not-reply" ) ;
$mail->AddAttachment( "c:\\mydog.jpg", "Isn't she cute?" ) ;
$mail->Subject = "Sorry for this test email!" ;
$mail->IsHTML( true ) ;
$mail->Body = file_get_contents( "c:\\myemail.html" ) ;
$mail->AltBody = "non-HTML mail client? Where are you from?" ;

if( !$mail->Send())
printf( "Sending Error: " . $mail->ErrorInfo . "\n" ) ;
else
printf( "Message has been sent successfully.\n" ) ;
?>

Friday, May 23, 2008

Publishing an Excel table as static html using jscript.

Oh man! I have worked on it a few days, posted numerous questions on various newsgroups, spent hours on the Internet and in a book store, and finaly I got what I needed!

Requirement:
I have a sheet (Sheet1) in my xlsx document (Excel 2007) which I wanted to save as a static html page using.
I want to use jscript run in the command line, so I could automate the process.
I don't want to use SaveAs( ..., 44 ) method because it creates the sheet name at the bottom.
I also don't want to have the ActiveX embedded into the page (no dynamic html.)

Assuming that the document is c:\mydoc\test.xlsx, I want to generate c:\mydoc\test.html file.

Here is the code of doit.js file:

ea = new ActiveXObject( "Excel.Application" ) ;
ea.DisplayAlerts = 0 ; /* Don't want to see any questions on the screen! */
wb = ea.Workbooks.Open( "c:\\mydoc\\test.xlsx" ) ;
po = wb.PublishObjects ;
po.Add( 1, "c:\\mydoc\\test.html", "Sheet1" ) ; /* 1 == static html. */
po.Item( 1 ).Publish( true ) ; /* Yahoo! */
wb.Close( false ) ; /* I don't want to save the newly added PublishObject */

Isn't that cool!